我每天用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 回答
您同时拥有
:set autoindent
和:set cindent
. 后者优先于前者,并且对您所抱怨的行为负责,因为它错误地将text:
解释为标签 .如果您只想为某些文件类型启用选项,请改用
:setlocal cindent
,并将相应的:setlocal
命令放入~/.vim/after/ftplugin/<filetype>.vim
,其中<filetype>
是实际文件类型(例如c
) . (这要求你有:filetype plugin on
;使用after目录可以覆盖$VIMRUNTIME/ftplugin/<filetype>.vim
完成的任何默认文件类型设置 . )或者,您可以直接在
~/.vimrc
中定义:autocmd FileType <filetype> setlocal cindent
,但是一旦您有许多自定义项,这往往会变得难以处理 .