| | 158 | 5.Search: |
| | 159 | |
| | 160 | To search the word After the cursor uses the backslash key and then write the word and press enter. |
| | 161 | |
| | 162 | `:/word` |
| | 163 | |
| | 164 | - Use `:n` to move on next matching word |
| | 165 | |
| | 166 | - Use `:N` to move on previous matching word |
| | 167 | |
| | 168 | |
| | 169 | 6.Search and Replace: |
| | 170 | |
| | 171 | To replace the word in file use s/ command in vim like |
| | 172 | |
| | 173 | `:s/searchword/replaceword/` |
| | 174 | |
| | 175 | To do replace all occurrence of word use g |
| | 176 | |
| | 177 | `:s/searchword/replaceword/g` |
| | 178 | |
| | 179 | This command will replace the word globally. |
| | 180 | |
| | 181 | To confirm before replacements of words use gc |
| | 182 | |
| | 183 | `:s/searchword/replaceword/gc` |
| | 184 | |
| | 185 | To use this command in the whole file use % before the command |
| | 186 | |
| | 187 | `:%s/searchword/replaceword/gc` |
| | 188 | |