views:

1665

answers:

6

This has bugged me for a long time, and try as I might I can't find a way round it.

When I'm editing text (specifically latex, but that doesn't matter) files, I want it to auto-wrap at 80 columns. It does this, except if I happen to be in the middle of a parenthetical clause, it indents the text which is very annoying. For example, this works fine

Here is some text... over
two lines.

but this doesn't

Here is some text... (over
                      two
                      lines

If anyone can tell me how to turn this off (just for text/latex files) I'd be really grateful. Presumably it has something to do with the fact that this is desired behaviour in C, but I still can't figure out what's wrong.

A: 

:set noai

sets no auto indent tt may be smartindent though. Check out the doc and see if you can find something more

http://www.vim.org/htmldoc/indent.html

PintSizedCat
Nope. No difference.
Draemon
+2  A: 

You can have a look at the autoindent option :

autoindent - ai

Copy indent from current line when starting a new line (typing in Insert mode or when using the "o" or "O" command). If you do not type anything on the new line except and then type or , the indent is deleted again. When autoindent is on, formatting (with the "gq" command or when you reach 'textwidth' in Insert mode) uses the indentation of the first line. When 'smartindent' or 'cindent' is on the indent is changed in specific cases. The 'autoindent' option is reset when the 'paste' option is set. {small difference from Vi: After the indent is deleted when typing or , the cursor position when moving up or down is after the deleted indent; Vi puts the cursor somewhere in the deleted indent}.

claferri
Ah. cindent appears to be the culprit. I'd tried autoindent and smartindent but they made no difference.What's the best way to set this for text/latex files?
Draemon
look at my other answer, i think you'll have the solution with filetype indent.
claferri
+2  A: 

There are three options you may need to turn off: set noai, set nosi, and setnocin (autoindent, smartindent, and cindent).

chaos
+1  A: 

From the official Vim documentation

filetype plugin indent on

This switches on three very clever mechanisms:

  1. Filetype detection. Whenever you start editing a file, Vim will try to figure out what kind of file this is. When you edit "main.c", Vim will see the ".c" extension and
    recognize this as a "c" filetype. When you edit a file that starts with "#!/bin/sh", Vim will recognize it as a "sh" filetype. The filetype detection is used for syntax highlighting and the other two
    items below. See |filetypes|.

  2. Using filetype plugin files Many different filetypes are edited with different options. For example,
    when you edit a "c" file, it's very useful to set the 'cindent' option to automatically indent the lines. These commonly useful option settings are
    included with Vim in filetype plugins. You can also add your own, see
    |write-filetype-plugin|.

  3. Using indent files When editing programs, the indent of a line can often be computed automatically. Vim comes with these indent rules for a number of filetypes. See |:filetype-indent-on| and 'indentexpr'.

claferri
I have these on already. Doesn't seem to change cindent
Draemon
I think you should try to look for a filetype-plugin wrote by someone with the same problem for latex files, or maybe you could try to write one.
claferri
ah, ok. I'll take a look at the latex one and see if it's easy to modify
Draemon
A: 
:set nocindent

The other options do nothing, and the filetype detection doesn't change it.

Draemon
A: 

This may be related, when pasting from gui into terminal window, vim cannot distinguish paste modes, so to stop any odd things from occuring:

set paste

then paste text

set nopaste

I had similar issues trying to paste xml text, it would just keep indenting. :)

The gui version of vim (gvim) can detect paste modes.

Rich