Quick Substitute Map

6 Points

Austin W Smith Austin W Smith

7 years ago

Do you notice that you type out :%s/x/y/g often? Then this is the snippet for you.

This will remap gs to type out the global substitution command and put your cursor in position to type what you want to find/replace more quickly.

The default mapping of gs will cause vim to sleep for 1 second, which isn't very useful and can still be done via the :sleep command.

" go substitute because the default map for sleeping is silly
nnoremap gs :%s//g<Left><Left>

" and here for those who have 'gdefault' enabled
nnoremap gs :%s//<Left>


valdoonicanlives 7 years ago

Very handy, thanks