Add "Stamp" functionality

2 Points

Bill Finn Bill Finn

9 years ago

I often find myself wanting to take a word and replacing it in just one or two spaces. Rather than writing up a s// command, I mapped the latter 'S' to accomplish this. It takes whatever is in register 0, strips whitespace, and overwrites the word (defined by diw) under the current cursor.

There is probably a more elegant way to do this...

nnoremap S :let @0 = substitute(@0, "\\s\\+$","","g")<cr>ea<space><esc>bdiw"0Plxb