I am using slash for searching for stuff within vim. I'd like to use the regex that I used for search in a command (a substitute command to be exact). Is there a simple way to do it?
s (substitute) will delete the current character and place the user in insert mode with the cursor between the two surrounding characters. 3s , for example, will delete the next three characters and place the user in insert mode. c (change) takes a vi/vim motion (such as w , j , b , etc.).
To search in the current file, you just need to type / in normal mode. Then, you need to type your search pattern, press enter , and the result becomes highlighted in your file. To go backward and forward through the results, you can type n and N (for n ext) respectively. Using / will search forward in the file.
On a character in the first line, press Ctrl-V (or Ctrl-Q if Ctrl-V is paste). Press jj to extend the visual block over three lines. Press $ to extend the visual block to the end of each line.
the subtitute command will use the last search if you do not specify it, so just use:
:s//<replacement>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With