From 74bcb2df881649310d064bcc8eac5aee1aa0cb7e Mon Sep 17 00:00:00 2001 From: vzvezda Date: Sat, 4 May 2019 15:20:01 +0700 Subject: [PATCH 1/2] Shortcut for up/down in quickfix or location list --- autoload/qf/wrap.vim | 10 ++++++++++ doc/qf.txt | 14 ++++++++++++++ plugin/qf.vim | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/autoload/qf/wrap.vim b/autoload/qf/wrap.vim index b543780..4799d48 100644 --- a/autoload/qf/wrap.vim +++ b/autoload/qf/wrap.vim @@ -46,4 +46,14 @@ function! qf#wrap#WrapCommand(direction, prefix) endif endfunction +" Navigates in quick fix window to next/prev entry if quckfix is opened, +" otherwise navigates up/down in location list. +function! qf#wrap#WrapCommandQfOrLoc(direction) + if qf#IsQfWindowOpen() + call qf#wrap#WrapCommand(a:direction, 'c') + else + call qf#wrap#WrapCommand(a:direction, 'l') + endif +endfunction + let &cpo = s:save_cpo diff --git a/doc/qf.txt b/doc/qf.txt index 148e9ed..5c62432 100644 --- a/doc/qf.txt +++ b/doc/qf.txt @@ -147,6 +147,20 @@ Example: > nmap (qf_loc_previous) nmap (qf_loc_next) < +------------------------------------------------------------------------------ + *(qf_qf_or_loc_previous)* + *(qf_qf_or_loc_next)* +Scope: global ~ +Default: none ~ + +Go up and down the quick quickfix list if one is opened. Othewise go up and +down in the current location list. In both cases it makes wrap around. + +Example: > + + nmap (qf_qf_or_loc_previous) + nmap (qf_qf_or_loc_next) + ------------------------------------------------------------------------------ *(qf_qf_switch)* Scope: global ~ diff --git a/plugin/qf.vim b/plugin/qf.vim index a876262..288f8b4 100644 --- a/plugin/qf.vim +++ b/plugin/qf.vim @@ -41,6 +41,11 @@ nnoremap (qf_qf_next) : call qf#wrap#WrapComm nnoremap (qf_loc_previous) : call qf#wrap#WrapCommand('up', 'l') nnoremap (qf_loc_next) : call qf#wrap#WrapCommand('down', 'l') + +" Go up and down quickfix or location list +nnoremap (qf_qf_or_loc_previous) : call qf#wrap#WrapCommandQfOrLoc('up') +nnoremap (qf_qf_or_loc_next) : call qf#wrap#WrapCommandQfOrLoc('down') + " Toggle quickfix list nnoremap (qf_qf_toggle) : call qf#toggle#ToggleQfWindow(0) nnoremap (qf_qf_toggle_stay) : call qf#toggle#ToggleQfWindow(1) From 07e18ab379a564676ad60b0a94145ee3c41e630c Mon Sep 17 00:00:00 2001 From: vzvezda Date: Sat, 4 May 2019 15:36:12 +0700 Subject: [PATCH 2/2] Added reference to the new commands --- doc/qf.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/qf.txt b/doc/qf.txt index 5c62432..e6c8b53 100644 --- a/doc/qf.txt +++ b/doc/qf.txt @@ -91,6 +91,8 @@ Global mappings: (qf_qf_next) ......................... |(qf_qf_next)| (qf_loc_previous) .................... |(qf_loc_previous)| (qf_loc_next) ........................ |(qf_loc_next)| + (qf_qf_or_loc_previous) .............. |(qf_qf_or_loc_previous)| + (qf_qf_or_loc_next) .................. |(qf_qf_or_loc_next)| (qf_qf_switch) ....................... |(qf_qf_switch)| (qf_qf_toggle) ....................... |(qf_qf_toggle)| (qf_qf_toggle_stay) .................. |(qf_qf_toggle_stay)|