Super quick search/replace

4 Points

Romain Lafourcade Romain Lafourcade

9 years ago

Place the cursor over the word you want to change and press the key combo to populate the command-line with the right stub:

-- :'{,'}s/word/ to substitute word in the current "paragraph",

-- :%s/word/ to substitute word in the whole buffer.

You only have to type the replacement and press <CR>.

nnoremap <key> :'{,'}s/\<<C-r>=expand('<cword>')<CR>\>/
nnoremap <KEY> :%s/\<<C-r>=expand('<cword>')<CR>\>/

Chris Penner

Chris Penner 9 years ago

If you often forget to add the g flag after (so it ACTUALLY replaces every instance) then try this:

```nnoremap :%s/\<=expand('')>//g

nnoremap :%s/\<=expand('')>//g ```

Romain Lafourcade

Romain Lafourcade 9 years ago

set gdefault is my friend.