[缓冲区浏览] 在开发过程中,经常会打开很多缓冲区,尤其是使用tag文件在不同函数间跳转时,会不知不觉打开很多文件。要知道自己当前打开了哪些缓冲区,可以使用vim的":ls"Ex命令查看。 开发过程中,又经常需要在不同文件间跳转。我习惯于使用"CTRL-^"来切换文件,这就需要知道文件所在的缓冲区编号。每次都使用":ls"来找缓冲区编号很麻烦,所以我使用BufExplorer插件来显示缓冲区的信息。 BufExplorer插件在此处下载:http://vim.sourceforge.net/scripts/script.PHP?script_id=42 下载后,把该文件在~/.vim/目录中解压缩,这会在你的~/.vim/plugin和~/.vim/doc目录中各放入一个文件: plugin/ bufexplorer.vim - bufexplorer插件 doc/ bufexplorer.txt - bufexplorer帮助文件 注:windows用户需要把这个插件解压在你的$vim/vimfiles或$HOME/vimfiles目录。 使用下面的命令生成帮助标签(下面的操作在vim中进行): :helptags ~/.vim/doc 然后,就可以使用":help bufexplorer"命令查看BufExplorer的帮助文件了。 BufExplorer功能比较简单,这里就不做介绍了。我的vimrc里这样设置BufExplorer插件: """""""""""""""""""""""""""""" " BufExplorer """""""""""""""""""""""""""""" let g:bufExplorerDefaultHelp=0 " Do not show default help. let g:bufExplorerShowRelativePath=1 " Show relative paths. let g:bufExplorerSortBy='mru' " Sort by most recently used. let g:bufExplorerSplitRight=0 " Split left. let g:bufExplorerSplitVertical=1 " Split vertically. let g:bufExplorerSplitVertSize = 30 " Split width let g:bufExplorerUseCurrentWindow=1 " Open in new window. autocmd BufWinEnter \[Buf\ List\] setl nonumber BufExplorer已经映射了几个键绑定,例如,使用",bv"就可以打开一个垂直分割窗口显示当前的缓冲区。 description With bufexplorer,you can quickly and easily switch between buffers by using the one of the default public interfaces: '\be' (normal open) or '\bs' (force horizontal split open) or '\bv' (force vertical split open) Once the bufexplorer window is open you can use the normal movement keys (hjkl) to move around and then use <Enter> or <Left-Mouse-Click> to select the buffer you would like to open. If you would like to have the selected buffer opened in a new tab,simply press either <Shift-Enter> or 't'. Please note that when opening a buffer in a tab,that if the buffer is already in another tab,bufexplorer can switch to that tab automatically for you if you would like. More about that in the supplied VIM help.
原文链接:https://www.f2er.com/bash/389042.html