thank you very much, for your elicitation to me.

i had write a filetype.vim, contain "au BufRead,BufNewFile *.txt
setf text",
and add one line "set ft=text" in my vimrc
then i write a file "text.vim" into "indent" folder, contain:
" Vim indent file
" Language:     plain text
" Maintainer:   StarWing
" Last Change:  2008-11-10 09:40:18

" Only Load this indent file when no other was loaded.
if exists("b:did_indent")
    finish
endif
let b:did_indent = 1

" indent for plain text
setlocal indentexpr=GetTextIndent()

" A small indent function for plain text {{{1
"
func! GetTextIndent()
    let cline = line('.')

    if &ft == 'c' || &ft == 'cpp'
        return cindent(cline)
    elseif !empty(&ft)
        return -1
    endif

    let nline = prevnonblank(cline - 1)
    if getline(cline - 1) =~ '^\s*$'
        if getline(nline - 1) =~ '^\s*$'
            return indent(nline)
        else
            return indent(nline) + &sw
        endif
    else
        if getline(nline - 1) =~ '^\s*$'
            return indent(nline) - &sw
        else
            return indent(nline)
        endif
    endif
endfunc
" }}}

" vim: ft=vim:fdm=marker:co=84:ts=4:sw=4:sta:et:nu

now it works well ~_~

thank you again ^_^

On 11月10日, 上午4时14分, fritzophrenic <[EMAIL PROTECTED]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to