When uncommenting code in vim, I want to have a macro to jump to the first uncommented line in a variety of files. I am using the nerdcommenter in Vim so (after highlighting the first commented line) I search for any line starting with any non #
or %
, but still containing some non-whitespace character with:
/^\s*\(#\|%\)\@!\S
But search replaces my search buffer. Can I do such a search without erasing my search buffer?
I see no such functionality in the nerdcommenter documentation.
You can save the last search to a variable like so:
let orig_search = @/
Then after you do the search, you can do this:
let @/ = orig_search