我正在使用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 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
答案 0 :(得分:21)
由于Vim附带了matchit插件,我需要做的就是激活它:
vim ~/.vimrc
然后将以下内容添加到.vimrc中:
set nocompatible
filetype plugin on
runtime macros/matchit.vim
答案 1 :(得分:20)
The page of the matchit
plugin说:
确保您有一行
:filetype plugin on
在vimrc
文件中。这启用了文件类型插件,其中许多都告诉我们
matchit.vim
匹配要使用的对。
答案 2 :(得分:19)
这一行
runtime macros/matchit.vim
是激活matchit的标准方式,它适用于我的所有机器。
键入
后,matchit是否有效:runtime macros/matchit.vim
在正常模式下?
答案 3 :(得分:5)
在我将一些vim插件更新为7.3的最新版本后,我开始遇到同样的问题。
但是当我跑步时
:MatchDebug
它解决了我的问题。
答案 4 :(得分:2)
我有一个问题,matchit在C ++ / C中找到正确的匹配括号时有评论的括号。以下步骤取自this forum post编写的this guy,为我解决了这个问题,并且几乎解释了整个过程的工作方式:
创建文件夹〜/ .vim / plugin(如果它不存在):
mkdir ~/.vim/plugin
使用名称创建文件 〜/ .vim / plugin / matchit.vim:
vi ~/.vim/plugin/matchit.vim
以及以下内容:
runtime macros/matchit.vim
创建目录〜/ .vim / doc(如果它还不存在):
mkdir ~/.vim/doc
将/usr/share/vim/vim73/macros/matchit.txt复制到〜/ .vim / doc /:
cp /usr/share/vim/vim73/macros/matchit.txt ~/.vim/doc/
打开vi
vi
并在其中执行以下内容:
:helptags ~/.vim/doc
确保〜/ .vimrc包含以下内容之一:
source $VIMRUNTIME/vimrc_example.vim
或
runtime vimrc_example.vim
或
filetype plugin on
或
filetype plugin indent on
在vimrc中添加以下自动命令:
" 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。
答案 5 :(得分:2)
仅供参考:在vim 8中runtime macros/matchit.vim
变为packadd! matchit
。 This网站帮助了我很多。
答案 6 :(得分:0)
我遇到过类似的问题。我已经使用VIM提供的脚本尝试runtime macros/matchit.vim
,但它无效。
所以我从http://www.vim.org/scripts/script.php?script_id=39下载了1.13.2版本的这个脚本,将其解压缩到〜/ vimfiles中,它可以工作!