├── .gitignore ├── LICENSE ├── README.md ├── autoload └── qfedit.vim ├── doc └── qfedit.txt └── plugin └── qfedit.vim /.gitignore: -------------------------------------------------------------------------------- 1 | /doc/tags 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2017 itchyny 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-qfedit 2 | ### Edit the quickfix/location list freely 3 | There's no need to configure for this plugin. Just edit the quickfix/location list buffer. 4 | 5 | ![qfedit](https://user-images.githubusercontent.com/375258/27513683-ef33dcc2-59aa-11e7-9135-2affaa8c7ece.gif) 6 | 7 | ## Installation 8 | Install with your favorite plugin manager. 9 | 10 | ## Author 11 | itchyny (https://github.com/itchyny) 12 | 13 | ## License 14 | This software is released under the MIT License, see LICENSE. 15 | -------------------------------------------------------------------------------- /autoload/qfedit.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " Filename: autoload/qfedit.vim 3 | " Author: itchyny 4 | " License: MIT License 5 | " Last Change: 2024/10/10 20:02:41. 6 | " ============================================================================= 7 | 8 | let s:save_cpo = &cpo 9 | set cpo&vim 10 | 11 | function! qfedit#new() abort 12 | if &l:buftype !=# 'quickfix' || !get(g:, 'qfedit_enable', 1) 13 | return 14 | endif 15 | let b:qfedit_items = qfedit#items(qfedit#getlist()) 16 | let b:qfedit_dir = getcwd() 17 | augroup qfedit-textchanged 18 | autocmd! * 19 | autocmd TextChanged call qfedit#change() 20 | augroup END 21 | let b:qfedit_changedtick = b:changedtick 22 | augroup qfedit-cursormoved 23 | autocmd! * 24 | autocmd CursorMoved call qfedit#moved() 25 | augroup END 26 | let b:qfedit_lastline = [line('$'), getline('$')] 27 | call qfedit#setlocal() 28 | endfunction 29 | 30 | function! qfedit#getlist() abort 31 | return qfedit#is_loclist() ? getloclist(0) : getqflist() 32 | endfunction 33 | 34 | function! qfedit#setlist(list) abort 35 | if qfedit#is_loclist() 36 | let title = getloclist(0, {'title': 0}) 37 | call setloclist(0, a:list, 'r') 38 | call setloclist(0, [], 'r', title) 39 | else 40 | let title = getqflist({'title': 0}) 41 | call setqflist(a:list, 'r') 42 | call setqflist([], 'r', title) 43 | endif 44 | endfunction 45 | 46 | function! qfedit#items(list) abort 47 | let items = {} 48 | for item in a:list 49 | let items[qfedit#line(item)] = item 50 | endfor 51 | return items 52 | endfunction 53 | 54 | function! qfedit#line(item) abort 55 | let fname = empty(get(a:item, 'module')) ? bufname(a:item.bufnr) : a:item.module 56 | if a:item.type ==# "\1" 57 | let fname = fnamemodify(fname, ':t') 58 | endif 59 | return ((a:item.bufnr ? fname : '') . '|' . 60 | \ (a:item.lnum ? a:item.lnum : '') . 61 | \ (get(a:item, 'end_lnum') && a:item.lnum != a:item.end_lnum ? '-' . a:item.end_lnum : '') . 62 | \ (a:item.col ? ' col ' . a:item.col . 63 | \ (get(a:item, 'end_col') && a:item.col != a:item.end_col ? '-' . a:item.end_col : '') 64 | \ : '') . 65 | \ qfedit#type(a:item.type, a:item.nr) . '| ' . 66 | \ (a:item.valid ? substitute(substitute(a:item.text, '\v^%(\t| )+', '', ''), '\v\n%(\n|\t| )*', ' ', 'g') 67 | \ : a:item.text) 68 | \ )[:1023] 69 | endfunction 70 | 71 | function! qfedit#type(type, nr) abort 72 | if a:type ==? 'W' 73 | let msg = ' warning' 74 | elseif a:type ==? 'I' 75 | let msg = ' info' 76 | elseif a:type ==? 'E' 77 | let msg = ' error' 78 | elseif a:type ==# "\0" || a:type ==# "\1" 79 | let msg = '' 80 | else 81 | let msg = ' ' . a:type 82 | endif 83 | if a:nr <= 0 84 | return msg 85 | endif 86 | return msg . ' ' . printf('%3d', a:nr) 87 | endfunction 88 | 89 | function! qfedit#moved() abort 90 | if !has_key(b:, 'qfedit_changedtick') 91 | augroup qfedit-cursormoved 92 | autocmd! * 93 | augroup END 94 | return 95 | endif 96 | if b:changedtick != b:qfedit_changedtick 97 | unlet! b:qfedit_changedtick 98 | call qfedit#change() 99 | augroup qfedit-cursormoved 100 | autocmd! * 101 | augroup END 102 | endif 103 | endfunction 104 | 105 | function! qfedit#change() abort 106 | let position = getpos('.') 107 | let view = winsaveview() 108 | call qfedit#restore() 109 | call winrestview(view) 110 | call setpos('.', position) 111 | call qfedit#setlocal() 112 | endfunction 113 | 114 | function! qfedit#restore() abort 115 | if b:qfedit_lastline[0] < line('$') 116 | \ && b:qfedit_lastline[1] ==# getline(b:qfedit_lastline[0]) 117 | call extend(b:qfedit_items, 118 | \ qfedit#items(qfedit#getlist()[b:qfedit_lastline[0]:])) 119 | endif 120 | let list = [] 121 | for line in map(getline(1, '$'), 'v:val[:1023]') 122 | if has_key(b:qfedit_items, line) 123 | call add(list, b:qfedit_items[line]) 124 | endif 125 | endfor 126 | let dir = getcwd() 127 | try 128 | lcd `=b:qfedit_dir` 129 | call qfedit#setlist(list) 130 | finally 131 | lcd `=dir` 132 | endtry 133 | let b:qfedit_lastline = [line('$'), getline('$')] 134 | endfunction 135 | 136 | function! qfedit#is_loclist() abort 137 | return get(get(getwininfo(win_getid()), 0, {}), 'loclist', 0) 138 | endfunction 139 | 140 | function! qfedit#setlocal() abort 141 | setlocal modifiable nomodified noswapfile 142 | endfunction 143 | 144 | let &cpo = s:save_cpo 145 | unlet s:save_cpo 146 | -------------------------------------------------------------------------------- /doc/qfedit.txt: -------------------------------------------------------------------------------- 1 | *qfedit.txt* Edit the quickfix list freely 2 | 3 | Version: 0.4 4 | Author: itchyny (https://github.com/itchyny) 5 | License: MIT License 6 | Repository: https://github.com/itchyny/vim-qfedit 7 | Last Change: 2019/05/09 15:30:11. 8 | 9 | CONTENTS *qfedit-contents* 10 | 11 | Introduction |qfedit-introduction| 12 | Options |qfedit-options| 13 | Functions |qfedit-functions| 14 | Examples |qfedit-examples| 15 | Changelog |qfedit-changelog| 16 | 17 | ============================================================================== 18 | INTRODUCTION *qfedit-introduction* 19 | This *qfedit* ( *vim-qfedit* *qfedit.vim* ) plugin enables you to edit the quickfix 20 | list freely as if it is a normal buffer. When you delete a line in the 21 | quickfix window, |qfedit| updates the quickfix list automatically. You can 22 | |d|elete, |y|ank, |p|aste, filter (|:g|/{pattern}/d, |:v|/{pattern}/d), |:sort| and |undo| 23 | the operations, whatever you can do in a normal buffer. 24 | 25 | ------------------------------------------------------------------------------ 26 | OPTIONS *qfedit-options* 27 | 28 | g:qfedit_enable *g:qfedit_enable* 29 | When you set this variable to 0, you cannot edit the quickfix list. 30 | The default value is 1. 31 | 32 | ============================================================================== 33 | CHANGELOG *qfedit-changelog* 34 | 35 | 0.4 2019-05-09 36 | - Retain previous quickfix title 37 | - Handle the contents update of quickfix window 38 | - Fix bug for helpgrep 39 | 40 | 0.3 2017-06-25 41 | - Use getwininfo to detect location list. 42 | - Fix bug for lines with leading tabs. 43 | - Add README.md. 44 | - Some other minor bug fixes and refactoring. 45 | 46 | 0.2 2015-03-13 47 | - Fix the position of set cpo&vim. 48 | 49 | 0.1 2015-01-22 50 | - Improve the type character. 51 | - Set {action} of |setqflist()| to 'r'. 52 | 53 | 0.0 2015-01-20 54 | - Initial commit. 55 | 56 | ============================================================================== 57 | vim:tw=78:sw=4:ts=8:ft=help:norl:noet: 58 | -------------------------------------------------------------------------------- /plugin/qfedit.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================= 2 | " Filename: plugin/qfedit.vim 3 | " Author: itchyny 4 | " License: MIT License 5 | " Last Change: 2017/06/25 12:34:11. 6 | " ============================================================================= 7 | 8 | if exists('g:loaded_qfedit') || !exists('##TextChanged') || !has('patch-7.4.2215') 9 | finish 10 | endif 11 | let g:loaded_qfedit = 1 12 | 13 | let s:save_cpo = &cpo 14 | set cpo&vim 15 | 16 | augroup qfedit 17 | autocmd! 18 | autocmd BufReadPost quickfix call qfedit#new() 19 | augroup END 20 | 21 | let &cpo = s:save_cpo 22 | unlet s:save_cpo 23 | --------------------------------------------------------------------------------