How to Search a Text in VIM
Mode provided by VIM
The Command mode :
k – Moves up one row. (Equivalent of Arrow up key )
j – Moves down one row. (Equivalent of Arrow down key )
l – Navigates one character to the right or moves forwards. (Equivalent of Arrow right key)
h – Navigates one character to the left or moves backward. (Equivalent of Arrow down key )
You can also prefix the keys with a numeric letter to move up or down a certain number of rows or move forward and backward a certain number of characters. For example,
6k – moves up 6 rows
4j – Moves down 4 rows
The Insert mode :
The ‘i’ key ( insert ) allows you to insert a character at the cursor’s current position.
The ‘a’ key ( append ) – This moves the cursor one character to the right and gets you to insert mode.
The ‘o’ key – This creates a new line below the current row and switches to insert mode.
The Visual mode :
Perform basic search operation in vim
To search text, you need to be in command mode. If you are in insert mode, simply press the ‘ESC’ key.
To perform a basic search of the string or text that you want, move to the beginning of the file and simply press the forward-slash ( / ) key. Then type the search string and press ENTER on the keyboard to start searching.
The forward-slash ( / ) key performs a forward search. It searches for the string or pattern from the current cursor position right up to the end of the file. To search for the next pattern, simply press the letter n on the keyboard.
To search backward, press the question mark symbol ( ? ), type the search string, and press ENTER on the keyboard. This searches the string from the current cursor position to the start of the file.
Search a complete word
To search for a complete word, begin by pressing the / or? Symbol. After that, type the \< symbol to mark the beginning of the word to be searched then /> to signify the end of the search word. Then finally, hit ENTER to commence the search.
0 comments:
Post a Comment