From 9ebd0187b51ac1c3a2953ec1916509d42ce502b6 Mon Sep 17 00:00:00 2001 From: Alex Efros Date: Sun, 10 Nov 2013 20:35:30 +0200 Subject: [PATCH 1/2] fix issue with delete wrong amount of spaces --- plugin/ctab.vim | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/plugin/ctab.vim b/plugin/ctab.vim index 4b105f6..5c85d99 100644 --- a/plugin/ctab.vim +++ b/plugin/ctab.vim @@ -150,27 +150,16 @@ fun! s:DoSmartDelete() let sts=(exists("b:insidetabs")?(b:insidetabs):((&sts==0)?(&sw):(&sts))) let ovc=virtcol('.') " Find where we are - let sp=(ovc % sts) " How many virtual characters to delete + let sp=((ovc-1) % sts) " How many virtual characters to delete if sp==0 | let sp=sts | endif " At least delete a whole tabstop - let vc=ovc-sp " Work out the new virtual column - " Find how many characters we need to delete (using \%v to do virtual column - " matching, and making sure we don't pass an invalid value to vc) - let uthlen=strlen(uptohere) - let bs= uthlen-((vc<1)?0:( match(uptohere,'\%'.(vc-1).'v'))) - let uthlen=uthlen-bs - " echo 'ovc = '.ovc.' sp = '.sp.' vc = '.vc.' bs = '.bs.' uthlen='.uthlen - if bs <= 0 | return '' | endif - " Delete the specifed number of whitespace characters up to the first non-whitespace - let ret='' - let bs=bs-1 - if uptohere[uthlen+bs] !~ '\s'| return '' | endif - while bs>=-1 - let bs=bs-1 - if uptohere[uthlen+bs] !~ '\s' | break | endif - let ret=ret."\" + let pos = strlen(uptohere) - sp + let bs = " \" " Disable deleting move than one space by first in some cases (not sure why it happens) + while uptohere[pos+sp-2] == ' ' && sp > 1 && pos+sp > 1 + let bs=bs . "\" + let sp=sp - 1 endwhile - return ret + return bs endfun fun! s:Column(line) From 97f1861acacd11bc974e00e05fb965ffca0f2784 Mon Sep 17 00:00:00 2001 From: Alex Efros Date: Sun, 10 Nov 2013 20:43:38 +0200 Subject: [PATCH 2/2] fix code indent --- plugin/ctab.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/ctab.vim b/plugin/ctab.vim index 5c85d99..8b2fc49 100644 --- a/plugin/ctab.vim +++ b/plugin/ctab.vim @@ -156,8 +156,8 @@ fun! s:DoSmartDelete() let pos = strlen(uptohere) - sp let bs = " \" " Disable deleting move than one space by first in some cases (not sure why it happens) while uptohere[pos+sp-2] == ' ' && sp > 1 && pos+sp > 1 - let bs=bs . "\" - let sp=sp - 1 + let bs=bs . "\" + let sp=sp - 1 endwhile return bs endfun