On Sunday, July 1, 2012 1:29:49 PM UTC-3, Ben Fritz wrote:
> On Saturday, June 30, 2012 5:34:35 PM UTC-5, Gerardo Marset wrote:
> > I have sofftabstop (and shiftwidth) set to 4, and expandtab enabled. Thus, 
> > when deleting groups of spaces, vim treats them as tabs and deletes them 4 
> > at a time. I want vim to do that only if from the start of the line and up 
> > to the cursor's position there's only spaces and nothing else.
> > Currently I'm doing the following:
> > 
> > inoremap <silent> <BS> <C-R>=fbs()<CR>
> > 
> > function fbs()
> >     if getline('.') =~ '^ \{' . (col('.') - 1) . '}' 
> >         return "\<BS>"
> >     endif
> >     return "\<Left>\<Del>"
> > endfunction
> > 
> > It works, but it breaks the repeat (dot) command, and I don't want that :). 
> > I think it's because of the <Left>. Any help (either modifying the previous 
> > code so that it doesn't break the dot command or coming up with a new one 
> > that doesn't) is appreciated.
> 
> You might try determining how many characters got deleted (getline in 
> combination with your cursor position command may help here) and insert 
> enough characters after the BS to make up for the difference. The thing 
> interrupting your undo sequence (and therefore messing up your repeat 
> command, '.') is the <Left> key, so you just need to avoid doing that. 
> Dropping out of insert mode (even temporarily with <C-O>) will do the same 
> thing unfortunately, and using setline() or setpos() is possible but will not 
> be reflected in the repeat sequence without a lot of effort and additional 
> mappings.

Thanks for the suggestion, but how could I insert a BS in the line without 
returning the function?

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to