0

In a BufWritePre to remove trailing spaces, my function uses a search/replace for \s\+$ over the current buffer. So after saving any buffer, this weird entry \s\+$ shows up in my search history. Is there a way to search-and-do-not-append-history? Or can a search history entry be automatically deleted (for example, the most recent entry)?

9
  • do you have a plugin for removing trailing whitespace? – Christian Brabandt Oct 14 '20 at 11:49
  • It's in my .vimrc (which I figured out about 3 seconds after posting), so I changed the question, since it is still a problem. – Byron Hawkins Oct 14 '20 at 11:52
  • 2
    :h :keeppatterns – Christian Brabandt Oct 14 '20 at 11:59
  • @ChristianBrabandt thanks, that works. So I tried googling for something like this, and found absolutely nothing related. Is there a better way to find out about features in vim? There's no way I can read about them all because it would take a year, and by then I would forget what I read. – Byron Hawkins Oct 14 '20 at 12:13
  • This may not be the answer you want to hear but learning how to do effective google searching will get you quite far. I found keeppatterns on my first google search and it's the top result. The search term: "vim don't overwrite search history". Top result: Vim search without overwriting "/ register (In this case the search term was quite straightforward, TBH. What did you look for, if you don't mind saying?) – B Layer Oct 14 '20 at 21:38
2

Perhaps you have an autocommand that is searching for trailing whitespace on save? That is what \s\+$ is searching for.

1
  • yes, that was it, and I changed the question accordingly. – Byron Hawkins Oct 14 '20 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.