Skip to content

Commit

Permalink
many changes, mostly to the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
romainl committed Jun 17, 2015
1 parent 0bfa3cb commit 0a4b199
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 67 deletions.
88 changes: 61 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

## Features

* disabled soft-wrapping,
* disabled relative numbers,
* no soft-wrapping,
* no relative numbers,
* quickfix buffers hidden from `:ls` and buffer navigation,
* Ack.vim-inspired mappings,
* wrapping mappings for `:cnext`, `:cprevious`, `:lnext`, `:lprevious`,
* jump to and from the location/quickfix window with a single mapping
* filter/restore the list
* perform commands on each line in the list
* perform commands on each file in the list
* automatically open the location/quickfix window after `:make`, `:grep`,
* open the location/quickfix window automatically after `:make`, `:grep`,
`:lvimgrep` and friends if there are valid locations/errors
* quit Vim if the last window is a location/quickfix window

Expand All @@ -27,54 +27,88 @@ Use your favorite plugin manager or dump the files below in their standard locat
~/.vim/plugin/qf.vim

# Windows
%userprofile%\vimfiles\plugin\qlist.vim
%userprofile%\vimfiles\after\ftplugin\qf.vim
%userprofile%\vimfiles\autoload\qf.vim
%userprofile%\vimfiles\plugin\qf.vim

## Usage

The following commands are available when the location/quickfix window is focused:

:Filter " Without argument, removes every item not found
" in the file of the current item.
:Filter foo " Removes every item that doesn't match with the
" supplied argument, either in the filename or
" in the description.
:Restore " Restores the list to its original state.
:Doline command " Executes 'command' on every line in the current list.
:Dofile command " Executes 'command' on every file in the current list.

## Configuration

The plugin provides two sets of mappings.
### Mappings available everywhere

Go up and down the quickfix list and wrap around

<Plug>QfCprevious
<Plug>QfCnext

Go up and down the location list and wrap around

<Plug>QfLprevious
<Plug>QfLnext

Jump to and from the location/quickfix window

* Mappings available in every buffer.
<Plug>QfSwitch

" <Home> and <End> go up and down the quickfix list and wrap around
nmap <Home> <Plug>QfCprevious
nmap <End> <Plug>QfCnext
Here is how you would map `<leader>n` to jump to the next error in the quickfix list:

" <C-Home> and <C-End> go up and down the location list and wrap around
nmap <C-Home> <Plug>QfLprevious
nmap <C-end> <Plug>QfLnext
nmap <leader>n <Plug>QfCnext

" ç jumps to and from the location/quickfix window
nmap ç <Plug>QfSwitch
### Ack.vim-inspired mappings available only in the quickfix window

Here is how you would map `<leader>n` to jump to the next error in the quickfix list:
s - open entry in a new horizontal window
v - open entry in a new vertical window.
t - open entry in a new tab.
o - open entry and come back
O - open entry and close the location/quickfix window.

nmap <leader>n <Plug>QfCprevious
Add the line below to your `vimrc` to enable that feature:

* Mappings available in the quickfix window only.
let g:qf_mapping_ack_style = 1

" Ack.vim-inspired mappings
" s - open entry in a new horizontal window
" v - open entry in a new vertical window.
" t - open entry in a new tab.
" o - open entry and come back
" O - open entry and close the location/quickfix window.
let g:qf_mapping_ack_style = 1
### Statusline customization

Here is how you would map `<leader>f` to filter the current list based on the filename under the cursor:
It is possible to define what comes before and after the default information displayed in the statusline. Feel free to play with the options below.

let g:qf_mapping_filter = '<leader>f'
let g:qf_statusline = {}
let g:qf_statusline.before = '%<\ '
let g:qf_statusline.after = '\ %f%=%l\/%-6L\ \ \ \ \ '

## AKNOWLEDGEMENTS

The "Ack.vim-inspired mappings" come from [Ack.vim](https://github.com/mileszs/ack.vim), obviously.

`:Doline` and `:Dofile` are inspired by these online resources:

* http://vimcasts.org/episodes/project-wide-find-and-replace/
* https://github.com/nelstrom/vim-qargs
* https://github.com/henrik/vim-qargs
* http://stackoverflow.com/questions/4792561/how-to-do-search-replace-with-ack-in-vim/4793316#4793316
* http://stackoverflow.com/a/5686810/546861
* and another one I can't find right now.

`:Filter` is adapted from the answers to [this question](http://stackoverflow.com/questions/15406138/is-it-possible-to-grep-vim%CA%BCs-quickfix).

## TODO

* Write a proper `help` file.
* Ask #vim's opinion.
* Export more options?
* Add a gifcast to the README?
* Add proper attribution for a few features.

## DONE

* Use `<Plug>` mappings.
* Add proper attribution for a few features.
26 changes: 7 additions & 19 deletions after/ftplugin/qf.vim
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
" qf.vim - Tame the quickfix window
" Maintainer: romainl <[email protected]>
" Version: 0.0.1
" Version: 0.0.2
" License: Vim License (see :help license)
" Location: after/ftplugin/qf.vim
" Website: https://github.com/romainl/vim-qf
"
" See qf.txt for help. This can be accessed by doing:
"
" :helptags ~/.vim/doc
" :help qf.txt

let s:save_cpo = &cpo
set cpo&vim

let b:undo_ftplugin = "setl fo< com< ofu<"

" text wrapping is useless in the quickfix window
" text wrapping is pretty much useless in the quickfix window
setlocal nowrap
" relative line numbers don't make much sense either
" but absolute numbers do
Expand All @@ -24,6 +19,11 @@ setlocal number
" we don't want quickfix buffers to pop up when doing :bn or :bp
set nobuflisted

" customize the statusline
if exists("g:qf_statusline")
execute "setlocal statusline=" . g:qf_statusline.before . "%{w:quickfix_title}" . g:qf_statusline.after
endif

" are we in a location list or a quickfix list?
let b:isLoc = len(getloclist(0)) > 0 ? 1 : 0

Expand Down Expand Up @@ -54,23 +54,11 @@ endif
" :Filter foo
command! -buffer -nargs=* Filter call qf#FilterList(<q-args>)

nnoremap <silent> <Plug>QfFilter :Filter <C-r><C-f><CR>
if !hasmapto('<Plug>QfFilter')
nmap <buffer> § <Plug>QfFilter
endif

" restore the location/quickfix list
" usage:
" :Restore
command! -buffer Restore call qf#RestoreList()

nnoremap <silent> <Plug>QfRestore :Restore<CR>
if !hasmapto('<Plug>QfRestore')
nmap <buffer> <F5> <Plug>QfRestore
endif

" do something on each line in the location/quickfix list
" usage:
" :Doline s/^/---
Expand Down
21 changes: 0 additions & 21 deletions plugin/qf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,6 @@ nnoremap <silent> <Plug>QfLnext :call qf#WrapCommand('up', 'l')<CR>
" jump to and from the location/quickfix window
nnoremap <expr> <silent> <Plug>QfSwitch &filetype == "qf" ? "<C-w>p" : "<C-w>b"
" default mappings
if !hasmapto('<Plug>QfCprevious')
nmap <Home> <Plug>QfCprevious
endif

if !hasmapto('<Plug>QfCnext')
nmap <End> <Plug>QfCnext
endif

if !hasmapto('<Plug>QfLprevious')
nmap <C-Home> <Plug>QfLprevious
endif

if !hasmapto('<Plug>QfLnext')
nmap <C-end> <Plug>QfLnext
endif

if !hasmapto('<Plug>QfSwitch')
nmap ç <Plug>QfSwitch
endif

" automatically open the location/quickfix window after :make, :grep,
" :lvimgrep and friends if there are valid locations/errors
augroup qf
Expand Down

0 comments on commit 0a4b199

Please sign in to comment.