MacVim的第二行是由tabstop w.r.t第一行关闭的

时间:2013-12-16 20:01:48

标签: vim macvim

我每天使用MacVim记下一些笔记。第二行是在日期之后缩进8个空格(tabstop),如下所示。

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.

我不想要第二行的额外空间。我希望它看起来像:

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.

如果第一行末尾有句号.,则不会发生此问题。到目前为止,它发生在(a)第一行末尾有冒号时(如本例所示)(b)如果第二行是第一行的延续。

我的.vimrc文件:

"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

有人可以告诉我如何解决这个问题吗?

1 个答案:

答案 0 :(得分:4)

您同时拥有:set autoindent:set cindent。后者优先于前者,并对您所抱怨的行为负责,因为它错误地将text:解释为标签。

如果您只想为某些文件类型启用选项,请改用:setlocal cindent,并将相应的:setlocal命令放入~/.vim/after/ftplugin/<filetype>.vim,其中<filetype>是实际的文件类型(例如c)。 (这要求您拥有:filetype plugin on;在目录之后使用可以覆盖$VIMRUNTIME/ftplugin/<filetype>.vim完成的任何默认文件类型设置。)

或者,您可以直接在:autocmd FileType <filetype> setlocal cindent中定义~/.vimrc,但是一旦您进行了多次自定义,这往往会变得难以处理。