On Nov 9, 1:21 am, StarWing <[EMAIL PROTECTED]> wrote:
> sometimes i write something in Vim, so i want it will be format as:
> -------------------------------
> this is a short
> paragraph i want to
> edit.
>
> and this is
> another paragraph.
>
> ------------------------------
> i mean, when i begin a new paragraph, i want Vim add four space before
> the first word. and when the text reached &textwidth(i set it to 80),
> i want Vim not to add four space from the second line to end of the
> paragraph. and i want it can work when i write like this:
> -------------------------------------
> some text and
> some more text.
>
> --------------------------------------
> i.e. if there more than 4 space in first line, Vim just delete 4 space
> when i begin to input the second line.
>
> i know a formatoption '2' can do it, but, however, i must input 4
> space manually, and delete 4 space manually when i begin to edit
> second line. can everything automatically?
>
> and, when i edit the comment of some source file, i set fo to
> 'croqmB2', but the option '2' can't work. when i use gq on comment,
> they will indent with first line, not second line, can i made it work?
You could mess with indentexpr. The following, I think, will do what
you want:
:set indentexpr=(prevnonblank(v:lnum-1)==v:lnum-1&&v:lnum!=1?0:4)
This will set the indent level to 0 if either the previous nonblank
line is equal to the previous line (i.e. there is text on the previous
line), and will set the indent level to 4 if the line is the first
line in the file, or the previous line is blank.
There may be a more efficient expression to use, but you'll probably
want to use the indentexpr to do it.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---