On 09/03/09 16:27, ivan budiselic wrote:
> Hi, I've searched around a bit for a solution to this problem, but
> didn't really come up with anything that works, and since it seems to be
> a pretty simple problem, I hope you won't mind too much that I'm posting
> the question here.
>
> Basically, the only formatting I want Vim to do for me is inserting the
> same indent as the previous line when I move to a new line (either by
> pressing enter in insert mode, or o, O etc. in normal mode). More
> specifically, I never ever want it to reformat anything I wrote
> previously. This has sort of bugged me before, but today I had a program
> I wrote in a crappy online editor that I had no way to export except
> copy/pasting which resulted in the whole thing being dumped into a
> single line.

Try

        :filetype indent off
        :set autoindent nosmartindent nocindent nolispindent indentexpr=

The ":set" line is as full as that in order to make sure that any indent 
settings already set by filetype-plugins are reset. If you don't use 
sessions, it would probably be enough to just write

        filetype indent off
        set autoindent nosmartindent

into your vimrc, after the call to vimrc_example.vim if you source it; 
or if you don't, replace

        filetype plugin indent on

(if present) by

        filetype plugin on

(or add the latter if you just don't have any ":filetype" command in 
your vimrc), and remove any "indent" options other than "autoindent" 
from any "set" statements that might already be there.

>
> The way the problem manifests itself is the following (for example): I
> set the indentation of the current line, move to the place I want to
> break the line at and press i<Enter> (there's probably a better way to
> do this (like the inverse of J or something), but I forgot about it if I
> ever knew it). At this point, the indentation of the (now previous) line
> changes.
>
> I've found that using :set paste sort of solves the problem, but then
> autoindent doesn't  work either.
>
> I think these are the relevant lines of my vimrc (I'm using Vim 7.2)
>
> autocmd FileType * set formatoptions= nocindent comments&
> autocmd FileType c,cpp,h set formatoptions=cro cindent
> comments=sr:/*,mb:*,ex:*/,://
> autocmd FileType css,htm,html,txt,xml set formatoptions= nocindent comments&

remove all these; any of them which you don't like are set by indent 
plugins already, and removing "indent" from "filetype [...] on" will 
avoid loading these; any useful ones are, I think, set by 
filetype-plugins, which are sourced automatically when needed, once you 
have set ":filetype plugin on".

>
> formatoptions in the first line used to be tcql, but I removed it hoping
> that might give me what I want (it didn't :). The file I'm editing
> should fall under the first category.
>
> Thanks for your help, and sorry for the probably dumb question.
>
> Ivan

Best regards,
Tony.
-- 
The Characters and incidents portrayed and the names used are fictitious and
any similarity to the names, characters, or history of any person is 
entirely
accidental and unintentional.
                                   Signed RICHARD M. NIXON
                  "Monty Python and the Holy Grail" PYTHON (MONTY) 
PICTURES LTD

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to