Difference between revisions of "IDE Window: Find"

From Lazarus wiki
Jump to navigationJump to search
(Add missing images; add syntax highlighting; fix typos; add linked navigation breadcrumbs)
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{IDE Window: Find}}
 
{{IDE Window: Find}}
  
If this dialog is invoked by Ctrl+F or by Search > Find then it the replace buttons and options are disabled.
+
== Navigation ==
  
If this dialog is invoked by Ctrl+R or by Search > Replace then the replace options will be enabled.
+
If this dialog is invoked by {{keypress|CTRL|F}} or {{keypress|CMD|F}}, or from the Lazarus IDE [[Main menu|Main Menu]] > [[Main menu#Search|Search]] > Find menu item, then the replace option is disabled and the associated buttons are not visible. The replace options can be enabled by checking the "Replace with" checkbox.
  
* Text to Find
+
If this dialog is invoked by {{keypress|CTRL|R}} or {{keypress|CMD|R}}, or from the Lazarus IDE [[Main menu|Main Menu]] > [[Main menu#Search|Search]] > Replace menu item, then the replace option will be enabled.
* Replace With
 
  
The above two comboboxes contain the last searched texts and replace patterns. Cursor Down will go back in history and fetch the last text to find.
+
[[Image:Search_Find_2_0_10.jpg]]  [[Image:Search_Replace_2_0_10.jpg]]
  
'''Hint''':
+
== Usage ==
You can choose, whether the IDE starts the dialog with the word at the cursor in the source editor or with a blank field in Environment -> Editor Options ->  General -> Find text at cursor
 
  
== Options ==
+
* Text to find
 +
* Replace with
  
* Case sensitive - distinguish lower case and upper case (a and A)
+
These two fields contain the last searched text and replacement text (if any). {{keypress|Down}} will go back in history and {{keypress|Up}} will go forward in history and recall the previous search text and replacement text.
* Whole words only - The found text must start at a word start and end at a word end
 
* Regular Expressions - see [[IDE regular expressions]]
 
* Multi line - not implemented yet
 
* Prompt on replace - ask before replacing (only enabled if replacing)
 
  
== Origin ==
+
{{Tip| You can choose whether the Lazarus IDE starts the dialog with the word at the cursor in the source editor or with a blank field in [[Main menu|Main Menu]] > [[Main menu#Tools|Tools]] > [[IDE Window: IDE Options Dialog|Options]] > [[IDE Window: Editor Options|Editor]] > [[IDE Window: Editor Options General|General]] > [[IDE Window: Editor Options General Misc|Miscellaneous]] > Find text at cursor.}}
  
* From Cursor - start search at cursor. If direction is forward, it searches till the end of the file
+
== Options ==
* Entire Scope - If direction is forward it starts searching at the beginning of the file and searches till the end.
 
  
== Scope ==
+
* Case sensitive - distinguish lowercase and uppercase (eg '''a''' and '''A''').
 +
* Whole words only - the found text must start at a word start and end at a word end.
 +
* Regular expressions - treat texts as [[IDE regular expressions]].
 +
* Multi line - the search does not stop at line ends or in other words: the found text can contain multiple lines. You can paste/copy multiple lines from the source editor to the Find field and you will see the line endings. These line endings cannot be created by normal keys. When searching with regular expressions you can use {{keypress|\|n}} (backslash plus n) as marker for line end characters. This also activates "multi-line" reg-expression option: for example, reg-expression "begin.*Application" will find such text:
  
* Global - search in whole file
+
<syntaxhighlight lang=pascal>
* Selected Text - limit the search to the selected text
+
begin
 +
  Something;
 +
  Application
 +
</syntaxhighlight>
  
'''Hint''': To search multiple files use Search -> [[IDE Window: Find in files|Find in files]].
+
* Prompt on replace - ask before replacing (only enabled if replacing).
  
== Direction ==
+
== Origin ==
  
* Forward search - search top to bottom. Each line is searched from left to right.
+
* From Cursor - start search at the cursor. If direction is forward, it searches until the end of the file.
* Backward search - search bottom to top. Each line is searched forward - left to right.
+
* Entire Scope - start search at the text edge (at the beginning for forward search, at the end for backward search)
  
== Regular Expressions ==
+
== Search Scope ==
  
=== Special Chars in Search Term ===
+
* Global - search in the whole file.
 +
* Selected Text - limit the search to the selected text.
  
If you checked Regular Expression, you can use the following special chars in the search term
+
{{Tip|To search multiple files at the same time, use [[Main menu|Main Menu]] > [[Main menu#Search|Search]] > [[IDE Window: Find in files|Find in files]].}}
(list is not complete)
 
  
;\\: Matches a single \
+
== Direction ==
;\n: Matches a newline
 
;\(: Matches a normal Bracket (
 
;(): Remembers the text matched. See $n in next section
 
;.: Any single one character
 
;[]: Exactly one of the chars listed inside the brackets ( [aeiou] => one vowel )
 
;*: 0, 1 or more of the char before ( .* => as many chars as possible )
 
;+:    1 or more of the char before ( .+ => as many chars as possible, minimum 1 )
 
;?: 1 or 0 of the char before
 
;*? +? ??: same as * + ?, but as little as possible
 
:|; either the term before or the term after
 
  
=== Special Chars in Replace Term ===
+
* Forward search - search top to bottom. Each line is searched from left to right.
 
+
* Backward search - search bottom to top. Each line is searched backward from left to right.
If you checked Regular Expression, you can use the followin special chars in the replace term
 
 
 
;\\: Inserts *one* normal backslash
 
;$n ${n}: Where n is a number between 1 and 15. Inserts a copy the part of the found text matching the nth  pair of bracket "()" in the search term (eg $1 for the first char after foo, if the search term was "foo(.)" )
 
;\n: Inserts a Linebreak
 
;\l \u: Lower or Uppercases the *next* Char. Use this in front of $n. \u$1 Will insert the match from the first brackets, but with it's first char made uppercase
 
;\L \U: Lower or Uppercase the *full* text of the next $n. The $n must follow immediately
 

Revision as of 13:29, 2 February 2021

Deutsch (de) English (en) suomi (fi) français (fr)

Navigation

If this dialog is invoked by CTRL+F or Cmd+F, or from the Lazarus IDE Main Menu > Search > Find menu item, then the replace option is disabled and the associated buttons are not visible. The replace options can be enabled by checking the "Replace with" checkbox.

If this dialog is invoked by CTRL+R or Cmd+R, or from the Lazarus IDE Main Menu > Search > Replace menu item, then the replace option will be enabled.

Search Find 2 0 10.jpg Search Replace 2 0 10.jpg

Usage

  • Text to find
  • Replace with

These two fields contain the last searched text and replacement text (if any). will go back in history and will go forward in history and recall the previous search text and replacement text.

Note-icon.png

Tip: You can choose whether the Lazarus IDE starts the dialog with the word at the cursor in the source editor or with a blank field in Main Menu > Tools > Options > Editor > General > Miscellaneous > Find text at cursor.

Options

  • Case sensitive - distinguish lowercase and uppercase (eg a and A).
  • Whole words only - the found text must start at a word start and end at a word end.
  • Regular expressions - treat texts as IDE regular expressions.
  • Multi line - the search does not stop at line ends or in other words: the found text can contain multiple lines. You can paste/copy multiple lines from the source editor to the Find field and you will see the line endings. These line endings cannot be created by normal keys. When searching with regular expressions you can use \+n (backslash plus n) as marker for line end characters. This also activates "multi-line" reg-expression option: for example, reg-expression "begin.*Application" will find such text:
 begin
   Something;
   Application
  • Prompt on replace - ask before replacing (only enabled if replacing).

Origin

  • From Cursor - start search at the cursor. If direction is forward, it searches until the end of the file.
  • Entire Scope - start search at the text edge (at the beginning for forward search, at the end for backward search)

Search Scope

  • Global - search in the whole file.
  • Selected Text - limit the search to the selected text.
Note-icon.png

Tip: To search multiple files at the same time, use Main Menu > Search > Find in files.

Direction

  • Forward search - search top to bottom. Each line is searched from left to right.
  • Backward search - search bottom to top. Each line is searched backward from left to right.