sponsor Vim development Vim logo Vim Book Ad

QFEnter : Open a Quickfix item in a window you choose

 script karma  Rating 68/20, Downloaded by 4544  Comments, bugs, improvements  Vim wiki

created by
Yoonsang Lee
 
script type
utility
 
description
More information : https://github.com/yssl/QFEnter

A normal mode example : https://f.cloud.github.com/assets/5915359/1632228/bb76dc72-5774-11e3-83d1-2933b95d5b81.gif
A visual mode example : https://f.cloud.github.com/assets/5915359/2006385/61c6f720-8717-11e3-806b-d0f276af3ef9.gif

# QFEnter

QFEnter allows you to open a Quickfix item in a window you choose.
You can choose the window by giving it a focus just before jumping to Quickfix window.
You can also open multiple items at once by including them in the visual block.

## Usage

In Quickfix window,

<Enter>, <2-LeftMouse>  
Normal mode : Open an item under cursor in a previously focused window.  
Visual mode : Open items in visual block in a 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 from a previously focused window.  
Visual mode : Open items in visual block in a sequence of new vertical splits from a previously focused window.

<Leader><Space>  
Normal mode : Open an item under cursor in a new horizontal split from a previously focused window.  
Visual mode : Open items in visual block in a sequence of new horizontal splits from a previously focused window.

<Leader><Tab>  
Normal mode : Open an item under cursor in a new tab.  
Visual mode : Open items in visual block in a sequence of new tabs.  
Quickfix window is automatically opened in the new tab to help you open other Quickfix items.

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>']
```

## Motivation

Default opening methods for QuickFix items are quite inconvenient,

- You cannot select a window in which a file is opened when you press `<Enter>` in Quickfix.  

  > 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.  
`:help quickfix`

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

- You also cannot specify the window when you use `Ctrl-W <Enter>`,
because Vim always create a new horizontal split window above Quickfix window and open a file in it.
There is even no command for 'open in new vertical split window'.

They are confusing and bother me every time, so I wrote a simple plugin to make up for these weak points.
It's name comes from the most basic way to open a file from Quickfix window - the `<Enter>` key.
 
install details
- Using plugin managers (recommended)
    - [Vundle] : Add `Bundle 'yssl/QFEnter'` to .vimrc & `:BundleInstall`
    - [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/`
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
QFEnter.zip 2.4.3 2022-10-16 7.0 Yoonsang Lee Add a new option g:qfenter_autoclose and deprecate g:qfenter_enable_autoquickfix. Thanks for the suggestion auto-close quickfix, minhduc0711!
QFEnter.zip 2.4.2 2022-10-15 7.0 Yoonsang Lee - Change the default value of g:qfenter_excluded_action to 'next'
- Fix the behavior in the case of undefined g:qfenter_excluded_action and g:qfenter_prevtabwin_policy
- Add option to use next window when excluded. Thanks for the PR, mmrwoods!
- Fix g:qfenter_prevtabwin_policy behavior when switchbuf=usetab or useopen is used
  and fix a bug with 'open' cmds. Thanks for the suggestions, Konfekt!
- Fix prevtabwin_policy tag name in doc. Thanks for the PR, tssm!
QFEnter.zip 2.4.1 2020-10-07 7.0 Yoonsang Lee 2.4.1
    Add an option for the policy to determine the previous window / tab' - g:qfenter_custom_map_list. Thanks for the suggestions, Konfekt and mckellyln!

2.4.0
    Remove the deprecated commands from 2.3.0: g:qfenter_*_map, g:qfenter_keep_quickfixfocus
    Support custom functions to specify target window through g:qfenter_custom_map_list. Thanks to p0deje!
    Add an option to prevent quickfix items from opening in windows of certain filetypes. Thanks to lsaint!
QFEnter.zip 2.3.1 2017-03-03 7.0 Yoonsang Lee     - Bug fix for deprecated variable(g:qfenter_keep_quickfixfocus) checking.
    - Update documents for customization.
QFEnter.zip 2.3.0 2017-02-28 7.0 Yoonsang Lee - Key mapping setup has totally changed for more flexible customizing.
QFEnter.zip 2.2.2 2015-05-25 7.0 Yoonsang Lee - Avoid messages when mappings are executed.
- E553 of cn & cp commands
- Modelines, clean up vimdoc formatting and edit text
- Support location list
QFEnter.zip 2.2.1 2014-03-17 7.0 Yoonsang Lee - now QFEnter supports vim's 'switchbuf' option.
  if you change 'switchbuf' option, QFEnter adapts its behavior to the changed option.
- thanks to sergey-vlasov!
- update document for 'switchbuf' option.
QFEnter.zip 2.1.0 2014-01-28 7.0 Yoonsang Lee - subdivide g:qfenter_keep_quickfixfocus option for each command.
  e.g. g:qfenter_keep_quickfixfocus.open, g:qfenter_keep_quickfixfocus.cnext,
  g:qfenter_keep_quickfixfocus.cprev
- bug fix : not updated window for already opened file when g:qfenter_keep_quickfixfocus==1
- thanks for mMontu!
QFEnter.zip 2.0.0 2014-01-27 7.0 Yoonsang Lee - visual mode support to open multiple Quickfix items at once
- add option to keep focus in Quicifix window after opening items  (g:qfenter_keep_quickfixfocus)
- support :cnext and :cprev command to open items
QFEnter-1.3.0.zip 1.3.0 2013-12-09 7.0 Yoonsang Lee improve features
  - improve auto quickfix open when 'open in new tab'
    - restore view(cursor position, scroll..) of quickfix window to auto-opened quickfix window
    - restore size of quickfix window to auto-opened quickfix window
    - now you don't need to provide g:qfenter_copen_modifier option. QFEnter now smartly determine whether the new quickfix window is botright or topleft, vertical or horizontal.
  - change g:qfenter_ttopen_map option name to g:qfenter_topen_map (backward compatibility maintained)
  - remove '<Tab><Tab>' from default mapping
QFEnter-1.2.0.zip 1.2.0 2013-12-08 7.0 Yoonsang Lee     - now, Quickfix window is automatically opened after "open in a new tab"
    - add options about Quickfix auto opening
    - add one more default mapping for "open in a new tab"
    - code refactoring
QFEnter-1.1.1.zip 1.1.1 2013-12-06 7.0 Yoonsang Lee     - change default mapping for "open a file in a new tab"
QFEnter.zip 1.1.0 2013-12-05 7.0 Yoonsang Lee - add new feature
     : open a file under cursor in new tab window.
     : register custom "cc" command with g:qfenter_cc_cmd
QFEnter.zip 1.0.0 2013-11-23 7.0 Yoonsang Lee Initial upload
ip used for rating: 54.226.25.246

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github