I want vim to ignore whitespace copy
Default cut x
will work same but
When i cut one whitespace character or a visual block of whitespaces with x
, vim register won't copy
like this thread, Vim Clever Whitespace Deletion
d
or dd
will cut but won't copy whitespace if it's only whitespaces
otherwise it will copy as usual
won't harm whitespaces like this situation: abc<space><space>
I only could do the first one
with this, vim won't copy single whitespaces when cut with x
function! Smart_Delete_x()
let temp = getreg('"', 1)
execute 'normal!' 'x'
if matchstr(@", '\_s*') == @" " if just whitespace
call setreg('"', temp)
call setreg('*', temp)
call setreg('+', temp)
call setreg('0', temp)
endif
endfunction
nnoremap <silent> x :call Smart_Delete_x()<CR>
I couldn't do the visual block one.
vim won't copy blocks of whitespaces when cut with x
but if the blocks has single or multiple character like
<space>
<space>
abc
only then vim will copy
dd
andv_d
. You'll need a new mapping and possibly a new function or modification of the existing function to overridev_x
. I highly recommend you read the book or parts thereof that statox recommended in another of your questions (Learning Vimscript the Hard Way.) It'll take some effort but you'll learn so much useful stuff.