Vim 它不起作用了
我正在使用Macvim 7.3快照57。我似乎无法让matchit在我的任何文件中工作 我在开始标签上按了%。它不带我到结束标签 我的vimrc文件:Vim 它不起作用了,vim,macvim,Vim,Macvim,我正在使用Macvim 7.3快照57。我似乎无法让matchit在我的任何文件中工作 我在开始标签上按了%。它不带我到结束标签 我的vimrc文件: " Pathogen settings call pathogen#runtime_append_all_bundles() call pathogen#helptags() set nocompatible set number set ruler set cursorline syntax on " Disable all blinki
" Pathogen settings
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
set nocompatible
set number
set ruler
set cursorline
syntax on
" Disable all blinking
set guicursor+=a:blinkon0
" Whitespace stuff
set nowrap
set tabstop=2
set shiftwidth=2
set expandtab
set cindent
set smartindent
set autoindent
set list listchars=tab:\ \ ,trail:·
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
" Status bar
set laststatus=2
" Start without the toolbar
set guioptions-=T
" Default gui color scheme
" "color default
" color molokai
color railscasts+
" Command-/ to toggle comments
map <D-/> :TComment<CR>j
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" Thorfile, Rakefile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Thorfile,config.ru} set ft=ruby
" Open split buffers below instead of above current buffer
set splitbelow
" Session options
let g:session_autoload = 1
let g:session_autosave = 1
" Buffer navigation
map <C-K> <C-W><C-K>
map <C-J> <C-W><C-W>
map <C-H> <C-W><C-H>
map <C-L> <C-W><C-L>
" Rails navigation options
nmap <leader>rc :Rcontroller
nmap <leader>rv :Rview
nmap <leader>rm :Rmodel
" Tab completion
" Also needed for better Rails navigation auto-completion
set wildmode=list:longest,list:full
" Open up side panel left (NERDTree) and right(Tagbar)
" nmap <leader>\ :NERDTreeToggle<CR> :TagbarToggle<CR>
nmap <leader>\ :call ToggleNERDTreeAndTagbar()<CR>
" Allow single click for NERDTree
let NERDTreeMouseMode = 3
let g:NERDTreeWinSize = 30
" autocmd VimEnter * NERDTree
" Tagbar options
let tagbar_singleclick = 1
let g:tagbar_sort = 0
let g:tagbar_width = 30
" autocmd VimEnter * nested TagbarOpen
" The Janus plugin sets this to noequalalways for the Zoominfo plugin
" However, we want to set this to equalalways instead, since we want to
" have equal window height when a new window is opened. i.e. via ctrl+w+s
set equalalways
" Matchit already installed in newer versions of vim.
" Don't need to add this onto pathogen bundle folder. We only need
" to configure it.
" Configure matchit so that it goes from opening tag to closing tag
au FileType html,eruby,rb,css,js,xml runtime! macros/matchit.vim
" Set backup and swp dir. Don't forget to clear tmp dir out once in a while
set backupdir=~/.vim/tmp/backup
set directory=~/.vim/tmp/swp
" Detect if a tab was closed, and ensure that height of main window fills the screen (100% height)
au TabEnter * let &lines = 100
" <leader>\ to open or close NERDTree and Tagbar, under the following conditions:
" 1) Only close both if NERDTree and Tagbar are both opened
" 2) Open both if NERDTree and Tagbar are closed OR if one is already opened
function! ToggleNERDTreeAndTagbar()
let w:jumpbacktohere = 1
" Detect which plugins are open
if exists('t:NERDTreeBufName')
let nerdtree_open = bufwinnr(t:NERDTreeBufName) != -1
else
let nerdtree_open = 0
endif
let tagbar_open = bufwinnr('__Tagbar__') != -1
" Perform the appropriate action
if nerdtree_open && tagbar_open
NERDTreeClose
TagbarClose
elseif nerdtree_open
TagbarOpen
elseif tagbar_open
NERDTree
else
NERDTree
TagbarOpen
endif
" Jump back to the original window
for window in range(1, winnr('$'))
execute window . 'wincmd w'
if exists('w:jumpbacktohere')
unlet w:jumpbacktohere
break
endif
endfor
endfunction
病原体设置
调用病原体#运行时_追加_所有_捆绑包()
调用病原体#helptags()
兼容模式
设定数
定尺
设置光标线
语法高亮
“禁用所有闪烁
设置guicursor+=a:blinkon0
“空白的东西
立即停止
设置tabstop=2
设置shiftwidth=2
设置扩展选项卡
集渣
智能对齐
自动缩进
设置列表listchars=tab:\\,轨迹:·
“搜索
高亮显示
在搜索中设置
置之不理
设置smartcase
“状态栏
设置laststatus=2
“不使用工具栏启动
设置guioptions-=T
“默认gui颜色方案
“”默认颜色
“颜色莫洛凯
彩色铁轨+
“命令-/切换注释
地图:TCommentj
“还记得文件中的最后一个位置吗
如果有(“自动MD”)
如果行(“\”)>0和行(“\”)这行
runtime macros/matchit.vim
是激活matchit的标准方式,在我所有的机器上都可以使用
你打字后它还能用吗
:runtime macros/matchit.vim
在正常模式下?显示:
确保你有一条像这样的线
:filetype plugin on
在vimrc
文件中。这将启用文件类型插件,其中许多插件
matchit.vim
使用哪些匹配对。我也遇到过类似的问题。我用vim提供的脚本尝试了运行时宏/matchit.vim,但没有成功。
因此,我从下载了1.13.2版的脚本,将其解压缩到~/vimfiles中,它就可以工作了 在我将一些vim插件更新到7.3的最新版本后,我开始出现同样的问题 但是当我跑的时候
:匹配调试
它为我解决了这个问题。当有注释大括号时,matchit在C++/C中查找正确的匹配大括号时遇到了问题。以下步骤来自于Write by,为我解决了这个问题,也大致解释了整个过程的工作方式:
mkdir ~/.vim/plugin
mkdir ~/.vim/doc
vi ~/.vim/plugin/matchit.vim
以及以下内容:
runtime macros/matchit.vim
mkdir ~/.vim/plugin
mkdir ~/.vim/doc
cp /usr/share/vim/vim73/macros/matchit.txt ~/.vim/doc/
vi
并在其中执行以下操作:
:helptags ~/.vim/doc
source $VIMRUNTIME/vimrc_example.vim
或
或
或
" make matchit work on C-like filetypes
" c and cpp are already handled by their ftplugin
au Filetype css,javascript
\ let b:match_words = &matchpairs
因为Vim附带matchit插件,所以我需要做的就是激活它:
vim ~/.vimrc
然后将以下内容添加到.vimrc中:
set nocompatible
filetype plugin on
runtime macros/matchit.vim
仅供参考:在vim 8
运行时宏/matchit.vim
中变为packadd!matchit
愚蠢的问题:matchit被激活用于html、eruby、rb、css、js、xml
,您是否有可能尝试将其用于其他文件类型?请尝试:帮助matchit安装
,它是专门为插件文档编写的,但它可以帮助您。在正常模式下键入:runtime macros/matchit.vim
无法立即工作,这让我很反感。您还必须执行:filetype detect
来为打开的文件激活它:MatchDebug
调用s:Match_debug()
,其第一行是让b:Match_debug=1“保存调试信息。
(函数的其余部分只定义了一些菜单)如果您搜索b:match_debug
,您将看到,如果设置了,那么脚本将不会使用其缓存的数据。在MacVim(77)上,我尝试了所有其他建议,这是唯一有效的建议(.vimrc
中的三行)。谢谢!我的理解是,~/.vimrc
文件的存在会自动关闭Vi兼容性。因此,:help compatible
“当在Vim启动时发现| vimrc |或| gvimrc |文件时,此选项将关闭。“事实上,我从~/.vimrc
文件中省略了set nocompatible
行,并且仍然能够通过添加以下两行来使用matchit.vim
。让b:match_words=&matchpairs
做什么呢?快速免责声明:不是原始作者(我的答案中引用的来源)这是我的解释,我接受了它,并以此作为我的解决方案。现在,这已经过时了,它搜索并匹配右括号/圆括号/etc模式。你可以在这里看到一些例子:链接不再工作了。非常感谢你让我知道。我想这就是为什么这种事情不被鼓励的原因。我已经删除了有问题的链接。对后代来说,这是:
set nocompatible
filetype plugin on
runtime macros/matchit.vim