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?
Use the String. replaceAll method to replace all spaces with underscores in a JavaScript string, e.g. string. replaceAll(' ', '_') . The replaceAll method returns a new string with all whitespace characters replaced by underscores.
To replace spaces with underscores in Python:Call the replace() method on the string. Pass a string containing a space and a string containing an underscore to the method. The replace() method will return a string with all spaces replaced by underscores.
When in visual mode type:
:s/\%V /_/g
see http://vim.wikia.com/wiki/VimTip438
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With