Draemon
Draemon

Reputation: 34711

How to prevent Vim indenting wrapped text in parentheses

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.

Upvotes: 14

Views: 6426

Answers (6)

Rich
Rich

Reputation: 41

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. :)

gvim, the gui version of vim, can detect paste modes.

Upvotes: 4

Draemon
Draemon

Reputation: 34711

:set nocindent

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

Upvotes: 14

claf
claf

Reputation: 9263

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'.

Upvotes: 2

chaos
chaos

Reputation: 124297

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

Upvotes: 5

claf
claf

Reputation: 9263

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}.

Upvotes: 3

Henry B
Henry B

Reputation: 8047

: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

Upvotes: 1

Related Questions