You are here

Grok Blog - vim search and replace.

Submitted by devblog on Sun, 02/07/2017 - 23:00

Search and Replace and Beginning and End of Line

I wanted to comment out a range of PHP lines using the single line // syntax so used the command 13,15s/^/^\/\/ featuring the caret symbol ^ to indicate that the replacement was from the beginning of the line, and was kind of surprised when the replacement text turned to be ^//. Coming to think of it the symbols ^ and $ are indicators of position, not characters, and all though there may be BOL and EOL characters they are not specified in the search. This is something I need to understand better.

asciidoc comes with the need to search and replace at end of line where you want the lines breaks eg. 13,15s/$/ \+/ and the same rule applied. There was no need to include $ in the command.

More links

Vertical Tabs

Add new comment