a/long/long/long/path/to/project/
ag のように長いパス ディレクトリで検索すると、結果リストには長いパスが含まれます。結果リストでプロジェクト パスを取得する方法はありますか?
の結果リストの例ag test a/long/long/long/path/to/project/
:
a/long/long/long/path/to/project/test.txt: test.....
a/long/long/long/path/to/project/js/test2.js: test: function() {
何を期待:
test.txt: test.....
js/test2.js: test: function() {
検索ではなく、指定したディレクトリ パスで検索するのはなぜcd
ですか? 私はこの方法で ag を使用して vim でプロジェクト全体の検索を行います。プロジェクト パスを見つけて、ag
指定されたパスで検索するために使用する vim コマンドに渡します。
解決
PS: 使ってますPlug 'mhinz/vim-grepper
function! VimGrepperConfig()
function! s:ag_at_project_root(keyword)
let root = s:find_root()
if !empty(root)
execute 'cd' root
execute 'GrepperAg' a:keyword
execute 'cd -'
else
execute 'GrepperAg' a:keyword
endif
endfunction
command! -nargs=1 AgAtProjectRoot call s:ag_at_project_root('<args>')
" ag search
no <Leader>/ :AgAtProjectRoot
endfunction
call VimGrepperConfig()