Am 12.02.2010 00:12, schrieb Ben Fritz:
On Feb 11, 3:00 pm, Joyce Tipping<jo...@spencertipping.com> wrote:
Hi guys,
I've been having an odd problem with my automatic text wrapping in vim. I
wrap my text with the "gq" command, sometimes as "gqap" (to wrap a
paragraph), sometimes as "gggqG" (to wrap the whole document). I've been
using vim for years and I don't recall ever having this issue.
Just recently, it started doing something really weird. I think a picture is
worth a thousand words, so here's a blog post I've been working on:
http://old.nabble.com/file/p27554664/vim-problem.png
Here's the contents of my vimrc:
[snip]
7 set smartindent
Assuming I understand your problem, this is the cause. I presume the
strange behavior you're referring to, is the lines after the line that
starts with "for a car...".
The 'smartindent' option is a deprecated option for indenting C code.
The C programming language has a construct called a "for loop" which
is (generally) a line that begins with the word, "for" and is indented
on the next line.
'smartindent' is not really meant for plain text editing, and you
generally get better results for C code by turning on filetype
indentation with "filetype indent plugin on" in your .vimrc.
As I understand it, "formatting" and "indenting" are different things.
I tried to find a clue in the help that 'smartindent' (and also 'cindent')
has an influence on formatting, but without success.
Seems to be so obvious that it's not worth mentioning?
On the other hand, I can't make a custom 'indentexpr' have the same
effect on formatting.
So it actually is somewhat surprising that 'smartindent' was the problem
(except for visitors of the #vim channel ^^)
--
Andy
A general recommendation against 'smartindent':
vimgor: Don't you mean stupidindent? In all seriousness, 'smartindent'
is an obsolete option for C-like syntax. It has been replaced with
'cindent', and setting 'cindent' also overrides 'smartindent'. Vim has
indentation support for many languages out-of-the-box, and setting
'smartindent' (or 'cindent', for that matter) in your .vimrc might
interfere with this. Use 'filetype indent on' and be happy.
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php