0

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.

jmlarson
  • 656
  • 5
  • 27

1 Answers1

1

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
EvergreenTree
  • 1,548
  • 2
  • 13
  • 27