Last active
May 8, 2024 17:00
-
-
Save robinp/0af93eae6ef661d5157e2d769fe280b0 to your computer and use it in GitHub Desktop.
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 characters
" Generated using ChatGPT, until https://github.com/neovim/neovim/issues/28544 fix gets released. | |
" Put in init.vim, select visual range in terminal, and call :VCB. | |
" Make sure that errorformat is set well (experiment with :cexpr "path/to/file:123 etc" or your actual format and see if quickfix gets it right) | |
function! VisualRangeToQuickfix() abort | |
" Get visually selected lines | |
let l:start = line("'<") | |
let l:end = line("'>") | |
" Get the current buffer number | |
let l:bufnr = bufnr('%') | |
" Extract the lines as a list | |
let l:lines = getline(l:start, l:end) | |
" Populate the Quickfix list using the errorformat | |
cexpr join(l:lines, "\n") | |
endfunction | |
command! -range VCB call VisualRangeToQuickfix() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment