Last active
November 7, 2021 20:57
-
-
Save romainl/3c7ee68125f822ec550c to your computer and use it in GitHub Desktop.
Revisions
-
romainl revised this gist
Apr 12, 2020 . 2 changed files with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ # This gist is no longer maintained. See https://github.com/romainl/vim-qlist for an up-to-date version. --- [My Vim-related gists](https://gist.github.com/romainl/4b9f139d2a8694612b924322de1025ce). File renamed without changes. -
romainl revised this gist
Mar 26, 2020 . 2 changed files with 3 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,3 @@ " This is an updated, more powerful, version of the function discussed here: " http://www.reddit.com/r/vim/comments/1rzvsm/do_any_of_you_redirect_results_of_i_to_the/ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # This gist is no longer maintained. See https://github.com/romainl/vim-qlist for an up-to-date version. -
romainl revised this gist
May 14, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ " ATTENTION! " ATTENTION! " This gist is no longer maintained. See https://github.com/romainl/vim-qlist " ATTENTION! " ATTENTION! -
romainl revised this gist
Apr 25, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,9 @@ " ATTENTION! " ATTENTION! " This gist is no longer maintained. See https://github.com/romainl/vim-ilist " ATTENTION! " ATTENTION! " This is an updated, more powerful, version of the function discussed here: " http://www.reddit.com/r/vim/comments/1rzvsm/do_any_of_you_redirect_results_of_i_to_the/ -
romainl revised this gist
Apr 11, 2015 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,17 +60,20 @@ function! List(command, selection, start_at_cursor, ...) cwindow endfunction " Override the built-in [I and ]I. nnoremap <silent> [I :call List("i", 0, 0)<CR> nnoremap <silent> ]I :call List("i", 0, 1)<CR> " Add [I and ]I for visual mode. xnoremap <silent> [I :<C-u>call List("i", 1, 0)<CR> xnoremap <silent> ]I :<C-u>call List("i", 1, 1)<CR> " Add the :Ilist command. command! -nargs=1 Ilist call List("i", 1, 0, <f-args>) " Override the built-in [D and ]D. nnoremap <silent> [D :call List("d", 0, 0)<CR> nnoremap <silent> ]D :call List("d", 0, 1)<CR> " Add [D and ]D for visual mode. xnoremap <silent> [D :<C-u>call List("d", 1, 0)<CR> xnoremap <silent> ]D :<C-u>call List("d", 1, 1)<CR> " Add the :Dlist command. command! -nargs=1 Dlist call List("d", 1, 0, <f-args>) -
romainl revised this gist
Apr 11, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,7 +44,7 @@ function! List(command, selection, start_at_cursor, ...) let qf_entries = [] for line in lines if line !~ '^\s*\d\+:' let filename = split(line, '\.\./')[-1] else let lnum = split(line)[1] let text = substitute(line, '^\s*.\{-}:\s*\S\{-}\s\s', "", "") -
romainl revised this gist
Apr 11, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,8 +47,8 @@ function! List(command, selection, start_at_cursor, ...) let filename = line else let lnum = split(line)[1] let text = substitute(line, '^\s*.\{-}:\s*\S\{-}\s\s', "", "") let col = match(text, a:selection ? search_pattern : expand("<cword>")) + 2 call add(qf_entries, {"filename" : filename, "lnum" : lnum, "col" : col, "text" : text}) endif endfor -
romainl revised this gist
Apr 11, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,10 @@ function! List(command, selection, start_at_cursor, ...) if line !~ '^\s*\d\+:' let filename = line else let lnum = split(line)[1] let text = join(split(line)[2:-1]) let col = match(text, a:selection ? search_pattern : expand("<cword>")) + 1 call add(qf_entries, {"filename" : filename, "lnum" : lnum, "col" : col, "text" : text}) endif endfor -
romainl revised this gist
Mar 29, 2015 . 1 changed file with 11 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,16 @@ " This is an updated, more powerful, version of the function discussed here: " http://www.reddit.com/r/vim/comments/1rzvsm/do_any_of_you_redirect_results_of_i_to_the/ " The purpose of this function is to make the results of ']I', '[I', ']D', '[D', ':ilist' and ':dlist' " easier to navigate and more persistant by using the quickfix window instead of the default list-like interface. function! List(command, selection, start_at_cursor, ...) " Derive the commands used below from the first argument. let excmd = a:command . "list" let normcmd = toupper(a:command) " If we are operating on a visual selection, redirect the output of '[I', ']I', '[D' or ']D'. " If we don't, redirect the output of ':ilist argument' or ':dlist argument'. let output = "" if a:selection if a:0 > 0 && len(a:1) > 0 @@ -29,16 +30,16 @@ function! List(command, selection, start_at_cursor, ...) redir END endif " Clean up the output. let lines = split(output, '\n') " Bail out on errors. if lines[0] =~ '^Error detected' echomsg 'Could not find "' . (a:selection ? search_pattern : expand("<cword>")) . '".' return endif " Our results may span multiple files so we need to build a relatively complex list based on filenames. let filename = "" let qf_entries = [] for line in lines @@ -49,13 +50,14 @@ function! List(command, selection, start_at_cursor, ...) endif endfor " Build the quickfix list from our results. call setqflist(qf_entries) " Open the quickfix window if there is something to show. cwindow endfunction " Override the built-in commands. nnoremap <silent> [I :call List("i", 0, 0)<CR> nnoremap <silent> ]I :call List("i", 0, 1)<CR> xnoremap <silent> [I :<C-u>call List("i", 1, 0)<CR> -
romainl revised this gist
Mar 29, 2015 . No changes.There are no files selected for viewing
-
romainl revised this gist
Mar 29, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,10 +7,10 @@ function! List(command, selection, start_at_cursor, ...) " derive the commands used below from the first argument let excmd = a:command . "list" let normcmd = toupper(a:command) " if we are operating on a visual selection, redirect the output of '[I', ']I', '[D' or ']D' " if we don't, redirect the output of ':ilist argument' or ':dlist argument' let output = "" if a:selection if a:0 > 0 && len(a:1) > 0 let search_pattern = a:1 -
romainl revised this gist
Mar 29, 2015 . 1 changed file with 15 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,16 @@ " This is an updated, more powerful, version of the function discussed here: " http://www.reddit.com/r/vim/comments/1rzvsm/do_any_of_you_redirect_results_of_i_to_the/ " This function shows ']I', '[I', ']D', '[D', ':ilist' and ':dlist' results — even spanning multiple files — in the quickfix window. function! List(command, selection, start_at_cursor, ...) " derive the commands used below from the first argument let excmd = a:command . "list" let normcmd = toupper(a:command) let output = "" " if we are operating on a visual selection, redirect the output of '[I', ']I', '[D' or ']D' " if we don't, redirect the output of ':ilist argument' or ':dlist argument' if a:selection if a:0 > 0 && len(a:1) > 0 let search_pattern = a:1 @@ -24,11 +28,17 @@ function! List(command, selection, start_at_cursor, ...) silent! execute 'normal! ' . (a:start_at_cursor ? ']' : '[') . normcmd redir END endif " clean up the output let lines = split(output, '\n') " bail out on errors if lines[0] =~ '^Error detected' echomsg 'Could not find "' . (a:selection ? search_pattern : expand("<cword>")) . '".' return endif " our results may span multiple files so we need to build a relatively complex list based on filenames let filename = "" let qf_entries = [] for line in lines @@ -38,7 +48,11 @@ function! List(command, selection, start_at_cursor, ...) call add(qf_entries, {"filename" : filename, "lnum" : split(line)[1], "text" : join(split(line)[2:-1])}) endif endfor " build the quickfix list from our results call setqflist(qf_entries) " open the quickfix window if there is something to show cwindow endfunction -
romainl revised this gist
Mar 27, 2015 . 1 changed file with 3 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,12 +3,12 @@ " that shows ]I, [I, ]D, [D, :ilist and :dlist results in the quickfix window, even spanning multiple files. function! List(command, selection, start_at_cursor, ...) let excmd = a:command . "list" let normcmd = toupper(a:command) let output = "" if a:selection if a:0 > 0 && len(a:1) > 0 let search_pattern = a:1 else let old_reg = @v @@ -24,32 +24,21 @@ function! List(command, selection, start_at_cursor, ...) silent! execute 'normal! ' . (a:start_at_cursor ? ']' : '[') . normcmd redir END endif let lines = split(output, '\n') if lines[0] =~ '^Error detected' echomsg 'Could not find "' . (a:selection ? search_pattern : expand("<cword>")) . '".' return endif let filename = "" let qf_entries = [] for line in lines if line !~ '^\s*\d\+:' let filename = line else call add(qf_entries, {"filename" : filename, "lnum" : split(line)[1], "text" : join(split(line)[2:-1])}) endif endfor call setqflist(qf_entries) cwindow endfunction -
romainl renamed this gist
Mar 17, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
romainl renamed this gist
Mar 17, 2015 . 1 changed file with 16 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,9 @@ " This is an updated, more powerful, version of the function discussed here: " http://www.reddit.com/r/vim/comments/1rzvsm/do_any_of_you_redirect_results_of_i_to_the/ " that shows ]I, [I, ]D, [D, :ilist and :dlist results in the quickfix window, even spanning multiple files. function! List(command, selection, start_at_cursor, ...) " derive the commands used below from the first argument let excmd = a:command . "list" let normcmd = toupper(a:command) @@ -19,11 +24,18 @@ function! List(command, selection, start_at_cursor, ...) silent! execute 'normal! ' . (a:start_at_cursor ? ']' : '[') . normcmd redir END endif " clean up the output let lines = split(output, '\n') " bail out on errors if lines[0] =~ '^Error detected' echomsg 'Could not find "' . (a:selection ? search_pattern : expand("<cword>")) . '".' return endif " our results may span multiple files so we need to build a relatively " complex list based on file names let filename = "" let qf_entries = [] for line in lines @@ -33,7 +45,11 @@ function! List(command, selection, start_at_cursor, ...) call add(qf_entries, {"filename" : filename, "lnum" : split(line)[1], "text" : join(split(line)[2:-1])}) endif endfor " build the quickfix list from our results call setqflist(qf_entries) " open the quickfix window if there is something to show cwindow endfunction -
romainl revised this gist
Mar 17, 2015 . No changes.There are no files selected for viewing
-
romainl revised this gist
Mar 17, 2015 . No changes.There are no files selected for viewing
-
romainl revised this gist
Mar 17, 2015 . No changes.There are no files selected for viewing
-
romainl created this gist
Mar 17, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ function! List(command, selection, start_at_cursor, ...) let excmd = a:command . "list" let normcmd = toupper(a:command) if a:selection if len(a:1) > 0 let search_pattern = a:1 else let old_reg = @v normal! gv"vy let search_pattern = substitute(escape(@v, '\/.*$^~[]'), '\\n', '\\n', 'g') let @v = old_reg endif redir => output silent! execute (a:start_at_cursor ? '+,$' : '') . excmd . ' /' . search_pattern redir END else redir => output silent! execute 'normal! ' . (a:start_at_cursor ? ']' : '[') . normcmd redir END endif let lines = split(output, '\n') if lines[0] =~ '^Error detected' echomsg 'Could not find "' . (a:selection ? search_pattern : expand("<cword>")) . '".' return endif let filename = "" let qf_entries = [] for line in lines if line =~ '^\S' let filename = line else call add(qf_entries, {"filename" : filename, "lnum" : split(line)[1], "text" : join(split(line)[2:-1])}) endif endfor call setqflist(qf_entries) cwindow endfunction nnoremap <silent> [I :call List("i", 0, 0)<CR> nnoremap <silent> ]I :call List("i", 0, 1)<CR> xnoremap <silent> [I :<C-u>call List("i", 1, 0)<CR> xnoremap <silent> ]I :<C-u>call List("i", 1, 1)<CR> command! -nargs=1 Ilist call List("i", 1, 0, <f-args>) nnoremap <silent> [D :call List("d", 0, 0)<CR> nnoremap <silent> ]D :call List("d", 0, 1)<CR> xnoremap <silent> [D :<C-u>call List("d", 1, 0)<CR> xnoremap <silent> ]D :<C-u>call List("d", 1, 1)<CR> command! -nargs=1 Dlist call List("d", 1, 0, <f-args>)