QFEnter


Ⅰ. 插件描述

Open a Quickfix item in a window you choose. (Vim plugin)

Ⅱ. 基本信息

创建日期:  2013-11-13
使用用户:  188
Github星:  123
插件作者:  yssl

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'yssl/qfenter'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'yssl/qfenter'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'yssl/qfenter'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/yssl/qfenter

Ⅳ. 文档说明

# QFEnter

QFEnter allows you to open items from Vim's quickfix or location list wherever you wish.

You can set a target window by giving it focus just before jumping to the
quickfix (or location list) window , or you can open items in new splits, vsplits, and tabs.
You can even open multiple items at once by visual selection!

A normal mode example:
qfenter

A visual mode example:
qfentervisualopt

Installation

  • Using plugin managers (recommended)

    • [Vundle] : Add Plugin 'yssl/QFEnter' to .vimrc & :PluginInstall
    • [NeoBundle] : Add NeoBundle 'yssl/QFEnter' to .vimrc & :NeoBundleInstall
    • [vim-plug] : Add Plug 'yssl/QFEnter' to .vimrc & :PlugInstall
  • Using [Pathogen]

    • cd ~/.vim/bundle; git clone https://github.com/yssl/QFEnter.git
  • Manual install (not recommended)

    • Download this plugin and extract it in ~/.vim/

Usage

In the quickfix (or location list) window,

<Enter>, <2-LeftMouse>
Normal mode : Open an item under cursor in the previously focused window.
Visual mode : Open items in visual selection in the previously focused

            window.  As a result, the last item appears in the window.

<Leader><Enter>
Normal mode : Open an item under cursor in a new vertical split of the

            previously focused window.  

Visual mode : Open items in visual selection in a sequence of new vertical

            splits from the previously focused window.

<Leader><Space>
Normal mode : Open an item under cursor in a new horizontal split from the

            previously focused window.  

Visual mode : Open items in visual selection in a sequence of new horizontal

            splits of the previously focused window.

<Leader><Tab>
Normal mode : Open an item under cursor in a new tab.
Visual mode : Open items in visual selection in a sequence of new tabs.

            By default, the quickfix window is automatically opened in the
            new tab to help you open other quickfix items. This behavior
            can be changed with the `g:qfenter_enable_autoquickfix` option.

Customization

You can change the key mappings in your .vimrc. The default setting is,

let g:qfenter_keymap = {}
let g:qfenter_keymap.open = ['<CR>', '<2-LeftMouse>']
let g:qfenter_keymap.vopen = ['<Leader><CR>']
let g:qfenter_keymap.hopen = ['<Leader><Space>']
let g:qfenter_keymap.topen = ['<Leader><Tab>']

If you're a [CtrlP] user, for instance, you might like these for familiarity:

let g:qfenter_keymap = {}
let g:qfenter_keymap.vopen = ['<C-v>']
let g:qfenter_keymap.hopen = ['<C-CR>', '<C-s>', '<C-x>']
let g:qfenter_keymap.topen = ['<C-t>']

Supported commands (such as open or vopen in above examples) are:

CommandsMeaning
openOpen items under cursor or in visual block in a previously focused window.
vopenOpen items under cursor or in visual block in new vertical splits from a previously focused window.
hopenOpen items under cursor or in visual block in new horizontal splits from a previously focused window.
topenOpen items under cursor or in visual block in new tabs.
cnextOpen items using :cnext command in a previously focused window.
vcnextOpen items using :cnext command in new vertical splits from a previously focused window.
hcnextOpen items using :cnext command in new horizontal splits from a previously focused window.
tcnextOpen items using :cnext command in new tabs.
cprevOpen items using :cprev command in a previously focused window.
vcprevOpen items using :cprev command in new vertical splits from a previously focused window.
hcprevOpen items using :cprev command in new horizontal splits from a previously focused window.
tcprevOpen items using :cprev command in new tabs.
open_keepSame as open, but the quickfix (or location list) window keeps focus after opening items.
vopen_keepSame as vopen, but the quickfix (or location list) window keeps focus after opening items.
hopen_keepSame as hopen, but the quickfix (or location list) window keeps focus after opening items.
topen_keepSame as topen, but the quickfix (or location list) window keeps focus after opening items.
cnext_keepSame as cnext, but the quickfix (or location list) window keeps focus after opening items.
vcnext_keepSame as vcnext, but the quickfix (or location list) window keeps focus after opening items.
hcnext_keepSame as hcnext, but the quickfix (or location list) window keeps focus after opening items.
tcnext_keepSame as tcnext, but the quickfix (or location list) window keeps focus after opening items.
cprev_keepSame as cprev, but the quickfix (or location list) window keeps focus after opening items.
vcprev_keepSame as vcprev, but the quickfix (or location list) window keeps focus after opening items.
hcprev_keepSame as hcprev, but the quickfix (or location list) window keeps focus after opening items.
tcprev_keepSame as tcprev, but the quickfix (or location list) window keeps focus after opening items.

For example, to open a next quickfix item in a previously focused window while keeping focus in the quickfix window by typing <Leader>a, you can use these:

let g:qfenter_keymap = {}
let g:qfenter_keymap.cnext_keep = ['<Leader>a']

Motivation

Vim's default means of opening items from the quickfix list are limited and
inconvenient:

  • You cannot select a window in which to open a file when you press <Enter>:

Hitting the <Enter> key or double-clicking the mouse on a line has the
same effect. The file containing the error is opened **in the window above
the quickfix window**.
-- from :help quickfix

It is inconsistent with other Quickfix commands like :cnext and :cprev
which open a file in a previously focused window.

  • You cannot decide where a horizontal split will be created when using `Ctrl-W
    <Enter>`, Vim always creates the new split window above the quickfix window.
  • There is no command at all for 'open in a new vertical split window'.

These are confusing and bothered me every time, so I wrote a simple plugin to
make up for these weak points. Its name comes from the most basic way to open
a file from the quickfix window -- the <Enter> key.

<!-- vim:set et sw=4 ts=4 tw=78: -->

添加新评论