This plugin enables quick switching to a buffer by its acronym.
The switching function is invoked by -
(minus) key. Additionally, _
(underscore) key lists all buffers before switching. It's OK to enter
either target buffer's acronym or number. There are a few rules
in matching acronyms.
g:buffer_acronym_with_path
controls whether an acronym should include the path component and the default is yes. If set to no,path/to/file.ext
is treated asfile.ext
.- Characters
/
,_
,.
and-
separate words in the file name. - Each uppercase letter starts a new word unless it follows an uppercase letter.
g:buffer_acronym_from_start
controls whether an acronym should start from the first word and the default is no.
For example, you have the following files opened in Vim.
awesome-program.cc
awesome-program.h
awesome_test.cc
Then
-apc<cr>
switches toawesome-program.cc
-aph<cr>
switches toawesome-program.h
-at<cr>
or-atc<cr>
switches toawesome_test.cc
-ap<tab>
cycles betweenawesome-program.cc
andawesome-program.h
-a<tab>
cycles through all three files.
When there are multiple matches, the first one is picked. So either -a<cr>
or -ap<cr>
switches to awesome-program.cc
.
If you don't have a preferred installation method, I recommend using Vundle. Assuming you have Vundle installed and configured, the following steps will install the plugin:
Add the following line to your ~/.vimrc
file
Plugin 'macroxue/vim-buffer-acronym'
Then run
:PluginInstall