sponsor Vim development Vim logo Vim Book Ad

GreedyBackspace.vim : Make backspace eat multiple whitespace characters

 script karma  Rating 26/15, Downloaded by 2477  Comments, bugs, improvements  Vim wiki

created by
Christian J. Robinson
 
script type
utility
 
description
This script will cause your backspace key to delete all the whitespace characters before the cursor when the cursor is on a whitespace character.

For example, if you typed "x       x" and then hit backspace twice, you'd only have "x".  This can be especially useful when auto/smart/c/expression indenting is on.

This script isn't very useful if you don't put "set backspace=indent,eol,start" or at least "set backsapce=indent,start" in your vimrc.


(Thanks to Tomi Mickelsson for testing and bug reports.)
 
install details
Source the script from your vimrc or just place it in your plugin directory.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
GreedyBackspace.vim 0.6 2022-08-22 9.0 Christian J. Robinson - Update to Vim 9 (no functionality added)
GreedyBackspace.vim 0.5 2005-11-23 6.0 Christian J. Robinson - When 'fileformat' was "dos" and g:greedybackspacenl was set too many characters could be deleted.
GreedyBackspace.vim 0.4 2005-11-16 6.0 Christian J. Robinson - g:greedybackspacenl = 1 wasn't working properly when the cursor was on the first character of a line.
GreedyBackspace.vim 0.3 2005-11-11 6.0 Christian J. Robinson - The 'smarttab' option was confusing the logic.
- You can now do ":let g:greedybackspacenl = 1" to cause the script to eat newlines as well.
GreedyBackspace.vim 0.2 2005-11-03 6.0 Christian J. Robinson - Commentary added.
- Syntax tweaks, no functional changes.
GreedyBackspace.vim 0.1 2005-10-31 6.0 Christian J. Robinson Initial upload
ip used for rating: 3.15.235.196

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github