Skip to content

Commit

Permalink
Merge branch 'preview'
Browse files Browse the repository at this point in the history
  • Loading branch information
romainl committed Oct 23, 2016
2 parents de278c9 + 4a77215 commit 19e45a8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion after/ftplugin/qf.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" vim-qf - Tame the quickfix window
" Maintainer: romainl <[email protected]>
" Version: 0.0.9
" Version: 0.1.0
" License: MIT
" Location: after/ftplugin/qf.vim
" Website: https://github.com/romainl/vim-qf
Expand Down Expand Up @@ -50,6 +50,8 @@ if exists("g:qf_mapping_ack_style")
else
nnoremap <buffer> O <CR>:cclose<CR>
endif
" preview entry under the cursor
nnoremap <buffer> p :call qf#PreviewFileUnderCursor()<CR>
endif

" filter the location/quickfix list
Expand Down
11 changes: 10 additions & 1 deletion autoload/qf.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" vim-qf - Tame the quickfix window
" Maintainer: romainl <[email protected]>
" Version: 0.0.9
" Version: 0.1.0
" License: MIT
" Location: autoload/qf.vim
" Website: https://github.com/romainl/vim-qf
Expand All @@ -13,6 +13,15 @@
let s:save_cpo = &cpo
set cpo&vim

" open the current entry in th preview window
function qf#PreviewFileUnderCursor()
let cur_list = b:isLoc == 1 ? getloclist('.') : getqflist()
let cur_line = getline(line('.'))
let cur_file = substitute(cur_line, '|.*$', '', '')
let cur_pos = substitute(cur_line, '^\(.\{-}|\)\(\d\+\)\(.*\)', '\2', '')
execute "pedit +" . cur_pos . " " cur_file
endfunction

" helper function
" " returns 1 if the window with the given number is a quickfix window
" " 0 if the window with the given number is not a quickfix window
Expand Down
1 change: 1 addition & 0 deletions doc/qf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Ack.vim-inspired mappings available only in location/quickfix windows:
t - open entry in a new tab
o - open entry and come back
O - open entry and close the location/quickfix window
p - open entry in a preview window

Add the line below to your vimrc to enable this feature: >
Expand Down
2 changes: 1 addition & 1 deletion plugin/qf.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" vim-qf - Tame the quickfix window
" Maintainer: romainl <[email protected]>
" Version: 0.0.9
" Version: 0.1.0
" License: MIT
" Location: plugin/qf.vim
" Website: https://github.com/romainl/vim-qf
Expand Down

0 comments on commit 19e45a8

Please sign in to comment.