diff options
author | Guangxiong Lin <[email protected]> | 2022-04-13 22:20:44 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2022-04-13 22:20:44 +0800 |
commit | 2ba3fc5be67f00aa43aac025866a0cf953f4b124 (patch) | |
tree | efc96ce63562baf07cb0cff42f065f252b3034db | |
parent | 10a79ab1be6dcf4c68cbf137ad8292aac6c4bffb (diff) | |
download | dotfiles-2ba3fc5be67f00aa43aac025866a0cf953f4b124.tar.gz dotfiles-2ba3fc5be67f00aa43aac025866a0cf953f4b124.tar.bz2 dotfiles-2ba3fc5be67f00aa43aac025866a0cf953f4b124.zip |
Implement my grep and find (vim)
-rw-r--r-- | .vim/after/autoload/gxfind.vim | 9 | ||||
-rw-r--r-- | .vim/after/plugin/find.vim | 3 | ||||
-rw-r--r-- | .vim/after/plugin/grep.vim | 1 | ||||
-rw-r--r-- | .vimrc | 4 |
4 files changed, 16 insertions, 1 deletions
diff --git a/.vim/after/autoload/gxfind.vim b/.vim/after/autoload/gxfind.vim new file mode 100644 index 0000000..90923a8 --- /dev/null +++ b/.vim/after/autoload/gxfind.vim @@ -0,0 +1,9 @@ +function! gxfind#find(args) + let findcmd = 'find . -type f ' . a:args + if executable('fd') + let findcmd = 'fd --hidden --type f ' . a:args . ' . ' + endif + + :cexpr system(findcmd) +endfunction + diff --git a/.vim/after/plugin/find.vim b/.vim/after/plugin/find.vim new file mode 100644 index 0000000..55c4fcb --- /dev/null +++ b/.vim/after/plugin/find.vim @@ -0,0 +1,3 @@ +command! -nargs=* Cexpr cexpr system(expand(<q-args>)) +command! -nargs=* -complete=file Find call gxfind#find(<q-args>) + diff --git a/.vim/after/plugin/grep.vim b/.vim/after/plugin/grep.vim index 0720e36..3d80ebb 100644 --- a/.vim/after/plugin/grep.vim +++ b/.vim/after/plugin/grep.vim @@ -4,3 +4,4 @@ if executable('rg') endif nnoremap <leader><leader>g :grep! <c-r>=expand('<cword>')<cr><cr> +nnoremap <leader>fr :grep!<space> @@ -20,6 +20,9 @@ set secure set exrc set noerrorbells +" use for populating filename in quickfix +set errorformat+=%f + " Use python3 first if has('python3') elseif has('python') @@ -127,4 +130,3 @@ packadd matchit if !empty(glob('~/.vim_local')) source ~/.vim_local endif - |