自从第一天使用Vim 3年以来,这个避风港一直在困扰着我。每当我试着通过转移到缩进一行 + 当行的第一个字符用“#”,它不能在所有的工作,无论文件类型(.PHP,.TXT等开始> )。因为#用于在PHP评论,我还用它装饰的文本文件类似:当该行的第一个字符是一个尖锐的#字符时,Vim编辑器缩进问题
# This is a comment ### 1. Instruction one # ------------ this is an sample --------------
我用Vim 7.2在Ubuntu具有以下.vimrc
设置
syntax on
set t_Co=256
set incsearch
set hlsearch
set number
set nowrap
set nowrapscan
set ignorecase
set et
set sw=4
set smarttab
set smartindent
set autoindent
set textwidth=0
set noequalalways
set formatoptions=1
set lbr
set vb
set foldmethod=marker
谢谢!
这并不能解决我的问题。我有'nosmartindent'和'filetype indent on',但仍然vim不让我缩进以'#'开头的行。当我在行中输入'#'作为第一个字符时,它也会将光标移动到第一列。任何线索? – 2013-04-15 11:16:31
@MichaelHärtl默认情况下,我有你完全相同的问题。默认情况下,Rmd具有这种恼人的行为,切换此行为的正确咒语是:':set nocindent'将其关闭,':set cindent'将它关闭在此处定义如下:http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash – 2017-04-15 07:59:17