Skip to main content
added 31 characters in body
Source Link
Matt
  • 21.6k
  • 1
  • 13
  • 25
  1. Use a function with range keyword (:h func-range) for processing your visual selection. Moreover, that also allows for [count] in Normal mode.

  2. Prefer buffer-local mappings whenever it makes sense.

    " using range-aware function function! QFdelete(bufnr) range " get current qflist let l:qfl = getqflist() " no need for filter() and such; just drop the items in range call remove(l:qfl, a:firstline - 1, a:lastline - 1) " replace items in the current list, do not make a new copy of it; " this also preserves the list title call setqflist([], 'r', {'items': l:qfl}) " restore current line number call cursorsetpos(a'.', [a:bufnr, a:firstline, 1, 0]) endfunction

    " using buffer-local mappings " note: still have to check &bt value to filter out :e quickfix and such augroup QFList | au! autocmd BufWinEnter quickfix if &bt ==# 'quickfix' autocmd BufWinEnter quickfix nnoremap dd :call QFdelete(bufnr()) autocmd BufWinEnter quickfix vnoremap d :call QFdelete(bufnr()) autocmd BufWinEnter quickfix endif augroup end

  1. Use a function with range keyword (:h func-range) for processing your visual selection. Moreover, that also allows for [count] in Normal mode.

  2. Prefer buffer-local mappings whenever it makes sense.

    " using range-aware function function! QFdelete() range " get current qflist let l:qfl = getqflist() " no need for filter() and such; just drop the items in range call remove(l:qfl, a:firstline - 1, a:lastline - 1) " replace items in the current list, do not make a new copy of it; " this also preserves the list title call setqflist([], 'r', {'items': l:qfl}) " restore current line number call cursor(a:firstline, 1) endfunction

    " using buffer-local mappings " note: still have to check &bt value to filter out :e quickfix and such augroup QFList | au! autocmd BufWinEnter quickfix if &bt ==# 'quickfix' autocmd BufWinEnter quickfix nnoremap dd :call QFdelete() autocmd BufWinEnter quickfix vnoremap d :call QFdelete() autocmd BufWinEnter quickfix endif augroup end

  1. Use a function with range keyword (:h func-range) for processing your visual selection. Moreover, that also allows for [count] in Normal mode.

  2. Prefer buffer-local mappings whenever it makes sense.

    " using range-aware function function! QFdelete(bufnr) range " get current qflist let l:qfl = getqflist() " no need for filter() and such; just drop the items in range call remove(l:qfl, a:firstline - 1, a:lastline - 1) " replace items in the current list, do not make a new copy of it; " this also preserves the list title call setqflist([], 'r', {'items': l:qfl}) " restore current line call setpos('.', [a:bufnr, a:firstline, 1, 0]) endfunction

    " using buffer-local mappings " note: still have to check &bt value to filter out :e quickfix and such augroup QFList | au! autocmd BufWinEnter quickfix if &bt ==# 'quickfix' autocmd BufWinEnter quickfix nnoremap dd :call QFdelete(bufnr()) autocmd BufWinEnter quickfix vnoremap d :call QFdelete(bufnr()) autocmd BufWinEnter quickfix endif augroup end

added 76 characters in body
Source Link
Matt
  • 21.6k
  • 1
  • 13
  • 25
  1. Use a function with range keyword (:h func-range) for processing your visual selection. Moreover, that also allows for [count] in Normal mode.

  2. Prefer buffer-local mappings whenever it makes sense.

    " using range-aware function function! QFdelete() range " get current qflist let l:qfl = getqflist() " no need for filter() and such; just drop the items in range call remove(l:qfl, a:firstline - 1, a:lastline - 1) " replace items in the current list, do not make a new copy of it; " this also preserves the list title call setqflist([], 'r', {'items': l:qfl}) " restore current line number call cursor(a:firstline, 1) endfunction

    " using buffer-local mappings " note: still have to check &bt value to filter out :e quickfix and such augroup QFList | au! autocmd BufWinEnter quickfix if &bt ==# 'quickfix' autocmd BufWinEnter quickfix nnoremap dd :call QFdelete() autocmd BufWinEnter quickfix vnoremap d :call QFdelete() autocmd BufWinEnter quickfix endif augroup end

  1. Use a function with range keyword (:h func-range) for processing your visual selection. Moreover, that also allows for [count] in Normal mode.

  2. Prefer buffer-local mappings whenever it makes sense.

    " using range-aware function function! QFdelete() range " get current qflist let l:qfl = getqflist() " no need for filter() and such; just drop the items in range call remove(l:qfl, a:firstline - 1, a:lastline - 1) " replace items in the current list, do not make a new copy of it; " this also preserves the list title call setqflist([], 'r', {'items': l:qfl}) endfunction

    " using buffer-local mappings " note: still have to check &bt value to filter out :e quickfix and such augroup QFList | au! autocmd BufWinEnter quickfix if &bt ==# 'quickfix' autocmd BufWinEnter quickfix nnoremap dd :call QFdelete() autocmd BufWinEnter quickfix vnoremap d :call QFdelete() autocmd BufWinEnter quickfix endif augroup end

  1. Use a function with range keyword (:h func-range) for processing your visual selection. Moreover, that also allows for [count] in Normal mode.

  2. Prefer buffer-local mappings whenever it makes sense.

    " using range-aware function function! QFdelete() range " get current qflist let l:qfl = getqflist() " no need for filter() and such; just drop the items in range call remove(l:qfl, a:firstline - 1, a:lastline - 1) " replace items in the current list, do not make a new copy of it; " this also preserves the list title call setqflist([], 'r', {'items': l:qfl}) " restore current line number call cursor(a:firstline, 1) endfunction

    " using buffer-local mappings " note: still have to check &bt value to filter out :e quickfix and such augroup QFList | au! autocmd BufWinEnter quickfix if &bt ==# 'quickfix' autocmd BufWinEnter quickfix nnoremap dd :call QFdelete() autocmd BufWinEnter quickfix vnoremap d :call QFdelete() autocmd BufWinEnter quickfix endif augroup end

Source Link
Matt
  • 21.6k
  • 1
  • 13
  • 25

  1. Use a function with range keyword (:h func-range) for processing your visual selection. Moreover, that also allows for [count] in Normal mode.

  2. Prefer buffer-local mappings whenever it makes sense.

    " using range-aware function function! QFdelete() range " get current qflist let l:qfl = getqflist() " no need for filter() and such; just drop the items in range call remove(l:qfl, a:firstline - 1, a:lastline - 1) " replace items in the current list, do not make a new copy of it; " this also preserves the list title call setqflist([], 'r', {'items': l:qfl}) endfunction

    " using buffer-local mappings " note: still have to check &bt value to filter out :e quickfix and such augroup QFList | au! autocmd BufWinEnter quickfix if &bt ==# 'quickfix' autocmd BufWinEnter quickfix nnoremap dd :call QFdelete() autocmd BufWinEnter quickfix vnoremap d :call QFdelete() autocmd BufWinEnter quickfix endif augroup end