In normal mode, press Tab or Shift-Tab to adjust the indent on the current line and position the cursor on the first nonblank character; in insert mode, press Shift-Tab to unindent; in visual mode, press Tab or Shift-Tab to adjust the indent on selected lines.
vim" in 'runtimepath'. This disables auto-indenting for files you will open. It will keep working in already opened files. Reset 'autoindent', 'cindent', 'smartindent' and/or 'indentexpr' to disable indenting in an opened file.
autoindent essentially tells vim to apply the indentation of the current line to the next (created by pressing enter in insert mode or with O or o in normal mode. smartindent reacts to the syntax/style of the code you are editing (especially for C). When having it on you also should have autoindent on.
I recently started using vim 7 (previously vim 6) and the smartindent
setting. For the most part, it works well, though I'm so used to typing a tab after an open brace that it is almost counter-productive.
However, there is one piece of maniacal behaviour. When editing a shell script, I try to create a comment at the current indent level, but smartindent
will have nothing to do with it. It insists that the comment must be at level 0 (no indent). What's worse, it breaks shift-right ('>>
' and friends) so that they do not work. This is outright insubordination, and I'd like to know what's the best way to fix it?
(I'm also not keen on smartindent
's ideas about indenting then
after if
.)
Preferred solutions will save me manual bashing - I'm being lazy. One option would be 'turn off smartindent
when editing shell scripts (leave it on for the rest)'. Another option would be guidelines on how to find the control script for smartindent
and what to edit to change the characteristics I don't like. The final option (which I don't need advice on how to do - just the hint that it is the best, or only, way to restore sanity) is to leave smartindent
unset.
I saw the vaguely related question on "(PHP and) annoying vim unindent rules"; it doesn't provide me with the direct answer, though maybe the cindent
and related items mentioned in there are in fact part of the answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With