Ⅰ. 插件描述
Tools to manipulate the quickfix windowⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'andrewradev/qftools-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'andrewradev/qftools-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'andrewradev/qftools-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/andrewradev/qftools.vim
Ⅳ. 文档说明
Note: Some of the functionality of this plugin overlaps with vim-qf. At this time, vim-qf seems more mature, so you might want to consider using that one instead.
Usage
This plugin provides various commands and mappings to work with the contents of the quickfix window.
Append, sort, merge
If you've executed a grep/ack command and you have a bunch of stuff in your quickfix window, but want to add another grep to it, this could help:
:Ack ProjectCollaborator
:Qfappend Ack UserCollaboratorThis will add the new search results to the end of the quickfix list, instead of replacing it. You could also swap the order by using :Qfprepend:
:Ack ProjectCollaborator
:Qfprepend Ack UserCollaboratorDuplicates should automatically be removed (two hits on the same line in the same file). However, the order is going to be the exact order of the first list + second list. To sort the current quickfix list alphabetically on the filename, use :Qfsort:
:Ack ProjectCollaborator
:Qfappend Ack UserCollaborator
:QfsortYou can also provide :Qfsort with a command and it'll execute that first, allowing you to do:
:Ack ProjectCollaborator
:Qfsort Qfappend Ack UserCollaboratorThe same commands are available without the "Qf" prefix within the actual buffer:
:Append
:Prepend
:Sort
:MergeFiltering entries
The plugin defines commands to remove lines by pattern:
:RemoveText <some-pattern> -> matches the text entries
:RemoveFile <some-pattern> -> matches the file entriesYou can also do the opposite and only keep files/text entries matching a particular pattern:
:KeepText <some-pattern>
:KeepFile <some-pattern>As an example, if you're searching for some code that gives you results in both javascript and handlebars files, you can remove all files with the .hbs extension from the quickfix list like so:
:RemoveFile \.hbs$Alternatively, you can keep only javascript files with:
:KeepFile \.js$This way, you can filter out test files, or narrow down the pattern you searched for within the found matches.
If you'd like to just remove, or keep, a range of lines, you can use these two commands:
<start>,<end>RemoveLines
<start>,<end>KeepLinesThe range is a perfectly normal range, so visual mode works with both of these. You can mark a visual-mode selection and run :RemoveLines to remove the selection from the quickfix window.
You can disable these commands by setting g:qftools_no_buffer_commands to 1.
You can also use the d mapping similar to the built-in one:
ddremoves a single line- visual-mode d removes the selected lines
d{motion}deletes the lines affected by the motion (for instance,dGwould delete all lines till the end of the buffer)
You can "undo" and "redo" deletions by using u and <c-r>. These mappings are not as powerful as Vim's built-in undo mechanism, but they should work mostly as expected. Currently, all they do is provide a thin wrapper to :colder and :cnewer.
You can disable these mappings by setting g:qftools_no_buffer_mappings to 1.
Open mappings
There are buffer-specific mappings defined that help you open files in different ways:
oopens the file the same way as<cr>, but it's closer to the home rowtopens the file in a new tabTopens the file in a new tab, without switching to itiopens the file in a new horizontal splitSopens the file in a new vertical split
They've been taken pretty much as-is from the ack.vim plugin. You can disable them by setting g:qftools_no_buffer_mappings to 1.