Loading ...
Sorry, an error occurred while loading the content.

132008Treat spaces as tabs only at the start of the line

Expand Messages
  • Gerardo Marset
    Jun 30, 2012
    • 0 Attachment
      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>"
      return "\<Left>\<Del>"

      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 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
    • Show all 7 messages in this topic