views:

75

answers:

1

This is an annoyance I've had for a long time.

(Nitpicky section: I prefer 4 space characters to tab characters. It's a lot easier to type "tab" instead of explaining that. When I say "tab", I mean "the action that happens when you press the tab key" which is probably more simply stated as "increase indentation".)

I'm using smartindent while editing a document where indentation has some significance. In "dumb" windows text editors I can press Shift+Tab to remove a tab or, more appropriately, decrease the indentation level of the current line. I can't figure out how to do this from edit mode in Vim; Shift+Tab seems to count just the same as Tab.

I know in Command mode << will decrease indentation. I want the equivalent in edit mode. These are the solutions I've found so far and why I don't like them, one in particular may be the key to the answer.

  1. Use Notepad++ or some other dumb editor. I've done this for a couple of years but I really miss Vim.
  2. Exit edit mode, use <<, enter edit mode. This just puts the cursor at column 0; if I wanted this I wouldn't have tried smartindent.
  3. Stop using smartindent. I don't decrease indent as often as I need to keep the same indent level; this would be a loss of productivity.
  4. The left arrow key seems to decrease the indent by one level. I'd rather something I can do without leaving the home row. This is the most promising choice.

Maybe there's an option I can set? Maybe I can rebind left arrow to something? (If it requires rebinding please explain in detail; I've never delved into reconfiguring (g)Vim.

+4  A: 

You can use Ctrl+D to back up one tab stop. This actually moves the whole line to the left one tab stop; Ctrl+T does the same thing to the right.

Note that these keystrokes only work in Insert mode (use << and >> for the equivalent in Command mode).

giftederic
nice, I didn't know that either :). Anyway, you can now also map <TAB> and <S-TAB> to those strokes in insert mode, if you really want to. Put in your .vimrc (or _vimrc on windows) two lines, without quotes: "inoremap <TAB> <C-T>" and "inoremap <S-TAB> <C-D>".
catchmeifyoutry