Max Yankov
Max Yankov

Reputation: 13297

Get rid of a typo in vim propagated with supertab

Occasionally I type in some identifier incorrectly, but don't notice and then repeat the exact same mistake by using SuperTab extension. In Sublime, I would use multi-cursor to quickly edit all the instances of this typo. Typing :%s/Identfier/Identifier/g takes longer; how can I do the same quicker and more effectively?

Upvotes: 1

Views: 79

Answers (2)

Kent
Kent

Reputation: 195039

there are following ways I can think of to save some typing:

with :s cmd

on one Identfier, press *, then :%s//Identifier/g

with :s and <c-r><c-w>

on one Identfier, press *, then :%s//<c-r><c-w>/g (after <c-r><c-w> do correction)

with (recursive) macro :

on one Identfier press *, then press qqffii<esc>n@qq then @q

with (recursive) macro and vim's spell checking feature :

:set spell to enable spellchecking then:

on one Identfier press *, then press qq1z=n@qq then @q

Upvotes: 5

sanmiguel
sanmiguel

Reputation: 4878

If it's fewer keystrokes you're after, with the cursor on the offending word, press * followed by :%s//Identifier/g.

Short of writing a special function to prompt for the replacement then replace all occurrences of the word under the cursor, I can't think of a more succinct way to do this.

Upvotes: 2

Related Questions