Second line in MacVim is off by tabstop w.r.t first line

I use MacVim to jot down some notes each day. The second line is indenting 8 spaces (tabstop) after the date as given below.

Dec 15th (Sun):
        John got a minor injury while playing. Wanted to take him to a 
        doctor but it was late Sunday night. Only ER was open 
        during those hours which cost us a lot for a small issue.

I do not want the extra space in second line. I want it to look like:

Dec 15th (Sun):
John got a minor injury while playing. Wanted to take him to a doctor 
but it was late Sunday night. Only ER was open during those hours which 
cost us a lot for a small issue.

This issue does not happen if there is a full stop . at the end of first line. So far, it happens when (a) there is colon at end of first line (as in this example) (b) if second line is continuation of first.

My .vimrc file:

"execute pathogen#infect()
call pathogen#infect() 

syntax on 
filetype plugin indent on 

"mappings 
"nmap  a=strftime("%Y-%m-%d %a %I:%M %p")
"imap  =strftime("%Y-%m-%d %a %I:%M %p")

nmap  a=strftime("[%I:%M%p]")
imap  =strftime("[%I:%M%p]")

set autoindent
set incsearch   " incremental search  
set hlsearch
set nu
set textwidth=74
set ruler       " show line & column # of cursor position. When there is
                " room, relative position of the text is shown w.r.t start
                " of file 

set timeoutlen=4000  " 4 sec timeout instead of default 1 sec for
                     " operations involving multiple keys such as tmux &
                     " screen

set mouse=a          " Allow mouse operations. Currently not working. 
set cindent          " Appropriate for c sntax. Look :help C-indenting   
set tabstop=8        " tab is 4 spaces long 
"set shiftwidth       " 
set expandtab        " replace tabs with 4 spaces 

"autocmd vimenter * NERDTree    " Load NERDTree whenever Vim starts 

set runtimepath^=~/.vim/bundle/ctrlp.vim " load CTRL-P plugin when Vim starts 

"set nocompatible      " by default

Can someone please let me know how to fix this?


You have both :set autoindent , and later :set cindent . The latter overrides the former, and is responsible for the behavior you're complaining about, because it mistakenly interprets the text: as a label.

If you only want to enable an option for certain filetypes, use :setlocal cindent instead, and put the corresponding :setlocal commands into ~/.vim/after/ftplugin/<filetype>.vim , where <filetype> is the actual filetype (eg c ). (This requires that you have :filetype plugin on ; use of the after directory allows you to override any default filetype settings done by $VIMRUNTIME/ftplugin/<filetype>.vim .)

Alternatively, you could define an :autocmd FileType <filetype> setlocal cindent directly in your ~/.vimrc , but this tends to become unwieldy once you have many customizations.

链接地址: http://www.djcxy.com/p/49524.html

上一篇: 新标签中的缩进更改

下一篇: MacVim的第二行由tabstop和第一行关闭