Tip #1389: Trailing white space aware Delete Key (Insert Mode)
tip karma |
Rating 1/3, Viewed by 713
|
created: |
|
November 16, 2006 14:59 |
|
complexity: |
|
basic |
author: |
|
pulp |
|
as of Vim: |
|
5.7 |
This function will extend the 'delete key' to delete trailing white spaces and empty lines at once.
Leading blanks are preserved.
Tested with: Insert Mode, set virtualedit=all, set backspace=2, blanks for ident
function! Smart_Del(...)
let line=getline (".")
let column = col(".")
let part2= strpart(line, column-1)
if part2 =~ '^\s*$' && part2!=""
let part1= strpart(line, 0, column-1)
call setline (".", part1)
endif
iunmap <silent> <DEL>
execute "normal i\<DEL>\<ESC>"
if column > 1
execute "normal l"
endif
inoremap <silent> <DEL> <C-o>: call Smart_Del()<CR>
endfunction
inoremap <silent> <DEL> <C-o>: call Smart_Del()<CR>
<<Vim and ocaml interpreter |
Give back movement to the Dvorak layout. >>
Additional Notes
|