Find and Replace Basics: Difference between revisions

From Bluefish Wiki
Jump to navigation Jump to search
(Created page with '__NOTOC__ __NOEDITSECTION__ {{Man2top |lang=en |rev=2.0.0 |Title=10. Basic Find and Replace |prev=Man 2 ch05s09 |Subtitle=Chapter V. Working with files and folders…')
 
m (moved Basic Find and Replace to Find and Replace Basics: Title updated (BV))
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
__NOTOC__
__NOEDITSECTION__
{{Man2top
{{Man2top
|lang=en
|lang=en
|rev=2.0.0
|rev=2.0.0
|st=d
|Title=10. Basic Find and Replace
|Title=10. Basic Find and Replace
|prev=Man 2 ch05s09
|prev=Man 2 ch05s09
Line 9: Line 8:
|next=Man 2 ch05s11
|next=Man 2 ch05s11
}}
}}
== 10. Basic Find and Replace ==
<div style="float:right; background-color:#E5ECF9;border:1px solid #3061C2;">
*[[#10.1. Searching for a word within a whole document|10.1. Searching for a word within a whole document]]
*[[#10.2. Setting limits to the search scope|10.2. Setting limits to the search scope]]
*[[#10.3. Case sensitive search|10.3. Case sensitive search]]
*[[#10.4. Overlapping searches|10.4. Overlapping searches]]
*[[#10.5. Retrieving previous search strings|10.5. Retrieving previous search strings]]
*[[#10.6. More on find|10.6. More on find]]
*[[#10.7. Replacing features|10.7. Replacing features]]
*[[#10.8. Retrieving previous replace strings|10.8. Retrieving previous replace strings]]
*[[#10.9. Changing letter case when replacing|10.9. Changing letter case when replacing]]
*[[#10.10. Choosing strings to replace|10.10. Choosing strings to replace]]
*[[#10.11. More on replace|10.11. More on replace]]
</div>
Bluefish offers a wide range of find and replace methods in the Edit menu, also available through the contextual menu within a document. Here we will explore the most basic ones. For advanced find and replace methods, see [[Man 2 ch06s05|Section 5, “Find and Replace”]].


=== 10.1. Searching for a word within a whole document ===
{{toc}}
Choose the Edit → Find... ('''Ctrl+F''') menu item. A Find dialog will be displayed. Enter the word to search for in the Search for: field. Then click OK.


[[File:Man2_find_word_whole.png]]
Bluefish offers a wide range of find and replace methods in the Edit menu, also available through the contextual menu within a document. Here we will explore the most basic ones. For advanced find and replace methods, see [[Man 2 ch06s05|Section 5, “Find and Replace”]].
 
'''Figure&nbsp;V.19.&nbsp;Finding a Word in a Document, from Start to End'''
 
If the word does not exist in the document, a small window pops up.
 
[[File:Man2_search_not_found.png]]
 
'''Figure&nbsp;V.20.&nbsp;Unsuccessful Search Window'''


If the search is successful, the document window scrolls up to the first occurrence of the string in the document and highlights it.
== 10.1. Searching for a word within a whole document ==
Choose the <tt>Edit → Find...</tt> ('''Ctrl+F''') menu item. A Find dialog will be displayed. Enter the word (or string) to search for in the <tt>Search for:</tt> field. Then click OK.
{|
|valign="bottom" align="center"|[[File:Man2_find_word_whole.png|none|frame|Finding a Word in a Document, from Start to End]]
|valign="bottom" align="center"|[[File:Man2_search_not_found.png|none|frame|If the word does not exist in the document, a small window pops up.]]
|}


Below is an example of a search applied to a shell script.  
If the search is successful, the document window scrolls up to the first occurrence of the string to search in the document and highlights it.


[[File:Man2_search_found.png]]
Below is an example of a search applied to a mediawiki document.  


'''Figure&nbsp;V.21.&nbsp;Highlighted Search Result in the Document Window'''
[[File:Man2_search_found.png|none|frame|Highlighted Search Result in the Document Window]]


To find a subsequent occurrence of the string, use the Edit → Find again ('''Ctrl+G''') menu item. If no further occurrence is found, a dialog will be displayed notifying you that no match was found.
To find a subsequent occurrence of the string, use <tt>the Edit → Find again</tt> ('''Ctrl+G''') menu item. If no further occurrence is found, a dialog will be displayed notifying you that no match was found.


=== 10.2. Setting limits to the search scope ===
== 10.2. Setting limits to the search scope ==
You may want to search for a string from the cursor location till the end of the document. Here is an example to search all <tt>name ==</tt> occurrences within a python script from a given location.
You may want to search for a string from the cursor location till the end of the document. Here is an example to search all <tt>name ==</tt> occurrences within a python script from a given location.


'''Procedure&nbsp;V.2.&nbsp;Searching from selection'''
'''Procedure&nbsp;V.2.&nbsp;Searching from selection'''


# Put the cursor where you want to start the search from in the document window <br/> [[File:Man2_find_limited_cursor.png]]<br/> '''Figure&nbsp;V.22.&nbsp;Setting the Cursor Location'''
# Put the cursor where you want to start the search from in the document window <br/> [[File:Man2_find_limited_cursor.png|none|frame|Setting the Cursor Location]]
# Open the Find... dialog
# Open the Find... dialog
# Enter your search string in the Search for: field
# Enter your search string in the Search for: field
# Choose Current position till end from the Starts at: pop up menu <br/> [[File:Man2_find_limited_dialog.png]]<br/> '''Figure&nbsp;V.23.&nbsp;Choosing a limited Search Method'''
# Choose Current position till end from the Starts at: pop up menu <br/> [[File:Man2_find_limited_dialog.png|none|frame|Choosing a limited Search Method]]
# Click OK.
# Click OK.


Here is the result:  
Here is the result:  


[[File:Man2_find_limited_result.png]]
[[File:Man2_find_limited_result.png|none|frame|Limited Search Result]]


'''Figure&nbsp;V.24.&nbsp;Limited Search Result'''


Notice that the search does not take into account the occurrence of the same string at line 50, since it is outside the search scope.
Notice that the search does not take into account the occurrence of the same string at line 50, since it is outside the search scope.
Line 69: Line 48:
You can also limit the search scope to a selection range. In that case, highlight the selection before the search, and choose Beginning of selection till end of selection from the Starts at: pop up menu in the Find dialog.
You can also limit the search scope to a selection range. In that case, highlight the selection before the search, and choose Beginning of selection till end of selection from the Starts at: pop up menu in the Find dialog.


=== 10.3. Case sensitive search ===
== 10.3. Case sensitive search ==
By default, the search process is case insensitive. If you want to make it case sensitive, just check the Match case box in the Find dialog.  
By default, the search process is case insensitive. If you want to make it case sensitive, just check the Match case box in the Find dialog.  


[[File:Man2_find_match_case.png]]
[[File:Man2_find_match_case.png|none|frame|Making the Search Case Sensitive]]


'''Figure&nbsp;V.25.&nbsp;Making the Search Case Sensitive'''


Here is the result applied to a ruby script:  
Here is the result applied to a ruby script:  


[[File:Man2_find_match_case_result.png]]
[[File:Man2_find_match_case_result.png|none|frame|Case Sensitive Search Result]]


'''Figure&nbsp;V.26.&nbsp;Case Sensitive Search Result'''


Notice again that the result does not catch the XML string at line 45, since the search string was xml and case sensitive search was requested.
Notice again that the result does not catch the XML string at line 45, since the search string was xml and case sensitive search was requested.


=== 10.4. Overlapping searches ===
== 10.4. Overlapping searches ==
It may occur that the document contains some kind of palindrome you want to search for. The "normal" find process does not retrieve all occurrences of that kind of string.
It may occur that the document contains some kind of palindrome you want to search for. The "normal" find process does not retrieve all occurrences of that kind of string.


In this case, you have to check the Overlap searches box in the Find dialog to retrieve all occurences of the string.  
In this case, you have to check the Overlap searches box in the Find dialog to retrieve all occurences of the string.  


[[File:Man2_find_basic_overlap.png]]
[[File:Man2_find_basic_overlap.png|none|frame|Finding overlapping Strings]]


'''Figure&nbsp;V.27.&nbsp;Finding overlapping Strings'''
The search (with '''Ctrl'''+'''F''', then '''Ctrl'''+'''G''') will give the following results:
{|
|valign="bottom" align="center"|[[File:Man2_find_basic_overlap_result.png|none|frame|First result]]
|valign="bottom" align="center"|[[File:Man2_find_basic_overlap_result2.png|none|frame|Second result]]
|valign="bottom" align="center"|[[File:Man2_find_basic_overlap_result3.png|none|frame|Third result ]]
|}


Applied to a shell script, the second search (with '''Ctrl'''+'''F''', then '''Ctrl'''+'''G''') will give the following result:
== 10.5. Retrieving previous search strings ==
 
[[File:Man2_find_basic_overlap_result.png]]
 
'''Figure&nbsp;V.28.&nbsp;An overlapping String retrieved with the Find Dialog'''
 
=== 10.5. Retrieving previous search strings ===
Notice that the pop up menu to the right of the Search for field in the Find dialog allows you to retrieve previous search strings. They are listed in reverse order by search history, providing quicker access to the most recent searches.  
Notice that the pop up menu to the right of the Search for field in the Find dialog allows you to retrieve previous search strings. They are listed in reverse order by search history, providing quicker access to the most recent searches.  


[[File:Man2_find_recent.png]]
[[File:Man2_find_recent.png|none|frame|Retrieving recent Searches]]


'''Figure&nbsp;V.29.&nbsp;Retrieving recent Searches'''


=== 10.6. More on find ===
== 10.6. More on find ==
For an explanation of the Bookmark results box of the Find dialog, see [[Man 2 ch06s04#Section 4.1, “Generating several bookmarks at once”|Section 4.1, “Generating several bookmarks at once”]].
For an explanation of the Bookmark results box of the Find dialog, see [[Man 2 ch06s04#Section 4.1. Generating several bookmarks at once|Section 4.1, "Generating several bookmarks at once”]].


You will find details on Find Again and Find from Selection in [[Man 2 ch06s05|Section 5, “Find and Replace”]].
You will find details on Find Again and Find from Selection in [[Man 2 ch06s05|Section 5, “Find and Replace”]].


For a quick way of switching from HTML entities to other types of encoding and changing letter cases, see [[Man 2 ch07s05#Section 5.1, “Special find and replace features”|Section 5.1, “Special find and replace features”]].
For a quick way of switching from HTML entities to other types of encoding and changing letter cases, see [[Man 2 ch07s05#Section 5.1. Special find and replace features|Section 5.1, “Special find and replace features”]].


=== 10.7. Replacing features ===
== 10.7. Replacing features ==
The Edit → Replace... ('''Ctrl+H''') menu item works the same way and has all the features, the Edit → Find... ('''Ctrl+F''') menu item offers.
The <tt>Edit → Replace...</tt> ('''Ctrl+H''') menu item works the same way and has all the features, the <tt>Edit → Find...</tt> ('''Ctrl+F''') menu item offers.


The Replace dialog is also accessible through the contextual menu within a document.
The Replace dialog is also accessible through the contextual menu within a document.


For the features common to the Find dialog, see [[#10.1, “Searching for a word within a whole document”|10.1, “Searching for a word within a whole document”]].
For the features common to the Find dialog, see [[#10.1. Searching for a word within a whole document|10.1, “Searching for a word within a whole document”]].


Here we will explain the features unique to the Replace dialog.  
Here we will explain the features unique to the Replace dialog.  


[[File:Man2_replace_dialog.png]]
[[File:Man2_replace_dialog.png|none|frame|The Replace Dialog]]


'''Figure&nbsp;V.30.&nbsp;The Replace Dialog'''


=== 10.8. Retrieving previous replace strings ===
== 10.8. Retrieving previous replace strings ==
As for the Search for field's pop up menu, the Replace with field's pop up menu allows you to retrieve previous strings used for replace, the most recent ones being at the top of the list.
As for the Search for field's pop up menu, the Replace with field's pop up menu allows you to retrieve previous strings used for replace, the most recent ones being at the top of the list.


=== 10.9. Changing letter case when replacing ===
== 10.9. Changing letter case when replacing ==
If you want to change letter case when replacing, use the Replace type pop up menu.
If you want to change letter case when replacing, use the Replace type pop up menu.


Line 138: Line 112:
Likewise, with the Lowercase replace type, the search string will be replaced with its lowercase translation.  
Likewise, with the Lowercase replace type, the search string will be replaced with its lowercase translation.  


[[File:Man2_replace_type_dialog.png]]
[[File:Man2_replace_type_dialog.png|none|frame|Changing letter Case when Replacing]]


'''Figure&nbsp;V.31.&nbsp;Changing letter Case when Replacing'''


Notice that in this case, the Replace with field is deactivated, thus not taken into account even if you have entered some string in it.
Notice that in this case, the Replace with field is deactivated, thus not taken into account even if you have entered some string in it.


=== 10.10. Choosing strings to replace ===
== 10.10. Choosing strings to replace ==
It may occur that you do not want to replace all search strings retrieved by the search process, but only some of them. In this case, check the Prompt before replace box. A Confirm replace dialog will appear for each retrieved string where you can choose to Skip this string, i.e. leave it as it is, Replace it, Replace all strings within the search scope, or Close the dialog, i.e. cancel the process.  
It may occur that you do not want to replace all search strings retrieved by the search process, but only some of them. <del>In this case, check the Prompt before replace box. A Confirm replace dialog will appear for each retrieved string where you can choose to Skip this string, i.e. leave it as it is, Replace it, Replace all strings within the search scope, or Close the dialog, i.e. cancel the process. </del>


[[File:Man2_replace_confirm_dialog.png]]
[[File:Man2_replace_confirm_dialog.png|none|frame|The Replace Confirm Dialog]]


'''Figure&nbsp;V.32.&nbsp;The Replace Confirm Dialog'''


If you want to replace only the first occurrence of a search string, check the Replace once box instead.
If you want to replace only the first occurrence of a search string, check the Replace once box instead.


=== 10.11. More on replace ===
== 10.11. More on replace ==
For further explanation on replace features within Bluefish, see [[Man 2 ch06s05|Section 5, “Find and Replace”]].
For further explanation on replace features within Bluefish, see [[Man 2 ch06s05|Section 5, “Find and Replace”]].


Line 165: Line 137:
|nextname=11.&nbsp;File types
|nextname=11.&nbsp;File types
}}
}}
[[Category:Manual 2]]

Latest revision as of 02:25, 1 July 2010


 

Bluefish offers a wide range of find and replace methods in the Edit menu, also available through the contextual menu within a document. Here we will explore the most basic ones. For advanced find and replace methods, see Section 5, “Find and Replace”.

10.1. Searching for a word within a whole document[edit]

Choose the Edit → Find... (Ctrl+F) menu item. A Find dialog will be displayed. Enter the word (or string) to search for in the Search for: field. Then click OK.

Finding a Word in a Document, from Start to End
If the word does not exist in the document, a small window pops up.

If the search is successful, the document window scrolls up to the first occurrence of the string to search in the document and highlights it.

Below is an example of a search applied to a mediawiki document.

Highlighted Search Result in the Document Window

To find a subsequent occurrence of the string, use the Edit → Find again (Ctrl+G) menu item. If no further occurrence is found, a dialog will be displayed notifying you that no match was found.

10.2. Setting limits to the search scope[edit]

You may want to search for a string from the cursor location till the end of the document. Here is an example to search all name == occurrences within a python script from a given location.

Procedure V.2. Searching from selection

  1. Put the cursor where you want to start the search from in the document window
    Setting the Cursor Location
  2. Open the Find... dialog
  3. Enter your search string in the Search for: field
  4. Choose Current position till end from the Starts at: pop up menu
    Choosing a limited Search Method
  5. Click OK.

Here is the result:

Limited Search Result


Notice that the search does not take into account the occurrence of the same string at line 50, since it is outside the search scope.

You can also limit the search scope to a selection range. In that case, highlight the selection before the search, and choose Beginning of selection till end of selection from the Starts at: pop up menu in the Find dialog.

10.3. Case sensitive search[edit]

By default, the search process is case insensitive. If you want to make it case sensitive, just check the Match case box in the Find dialog.

Making the Search Case Sensitive


Here is the result applied to a ruby script:

Case Sensitive Search Result


Notice again that the result does not catch the XML string at line 45, since the search string was xml and case sensitive search was requested.

10.4. Overlapping searches[edit]

It may occur that the document contains some kind of palindrome you want to search for. The "normal" find process does not retrieve all occurrences of that kind of string.

In this case, you have to check the Overlap searches box in the Find dialog to retrieve all occurences of the string.

Finding overlapping Strings

The search (with Ctrl+F, then Ctrl+G) will give the following results:

First result
Second result
Third result

10.5. Retrieving previous search strings[edit]

Notice that the pop up menu to the right of the Search for field in the Find dialog allows you to retrieve previous search strings. They are listed in reverse order by search history, providing quicker access to the most recent searches.

Retrieving recent Searches


10.6. More on find[edit]

For an explanation of the Bookmark results box of the Find dialog, see Section 4.1, "Generating several bookmarks at once”.

You will find details on Find Again and Find from Selection in Section 5, “Find and Replace”.

For a quick way of switching from HTML entities to other types of encoding and changing letter cases, see Section 5.1, “Special find and replace features”.

10.7. Replacing features[edit]

The Edit → Replace... (Ctrl+H) menu item works the same way and has all the features, the Edit → Find... (Ctrl+F) menu item offers.

The Replace dialog is also accessible through the contextual menu within a document.

For the features common to the Find dialog, see 10.1, “Searching for a word within a whole document”.

Here we will explain the features unique to the Replace dialog.

The Replace Dialog


10.8. Retrieving previous replace strings[edit]

As for the Search for field's pop up menu, the Replace with field's pop up menu allows you to retrieve previous strings used for replace, the most recent ones being at the top of the list.

10.9. Changing letter case when replacing[edit]

If you want to change letter case when replacing, use the Replace type pop up menu.

The default choice is Normal, that is the case is not changed.

With the Uppercase replace type, the search string will be replaced with its uppercase translation.

Likewise, with the Lowercase replace type, the search string will be replaced with its lowercase translation.

Changing letter Case when Replacing


Notice that in this case, the Replace with field is deactivated, thus not taken into account even if you have entered some string in it.

10.10. Choosing strings to replace[edit]

It may occur that you do not want to replace all search strings retrieved by the search process, but only some of them. In this case, check the Prompt before replace box. A Confirm replace dialog will appear for each retrieved string where you can choose to Skip this string, i.e. leave it as it is, Replace it, Replace all strings within the search scope, or Close the dialog, i.e. cancel the process.

The Replace Confirm Dialog


If you want to replace only the first occurrence of a search string, check the Replace once box instead.

10.11. More on replace[edit]

For further explanation on replace features within Bluefish, see Section 5, “Find and Replace”.