Reputation: 9621
I want to replace all spaces with an underscore, in the currently highlighted block i.e. not to apply it on the entire page.
How can I do this?
Upvotes: 8
Views: 5839
Reputation: 1474
You could go into visual mode (by typing v while in command mode) and then select the required text and thereafter enter the command mode (by typing ":"). This will automatically insert the selection range and then you could perform the necessary substitution.
Upvotes: 1
Reputation: 18979
When in visual mode type:
:s/\%V /_/g
see http://vim.wikia.com/wiki/VimTip438
Upvotes: 14