-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfcd.vim
More file actions
62 lines (54 loc) · 1.58 KB
/
fcd.vim
File metadata and controls
62 lines (54 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
" Do not load fcd.vim if is has already been loaded.
if exists("loaded_fcd")
finish
endif
let loaded_fcd = 1
" cd----------->
autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | call AutoLcd() | endif
let s:userFirstOpenVim = 1
function! AutoLcd(...)
if (s:userFirstOpenVim == 1 && isdirectory(expand("%:p")) ) " first open dir for not cd
"pass
else
execute "lcd %:p:h"
end
let s:userFirstOpenVim = 0
endfunction
" <-----------cd
" fastcd--------->
function! Fcd(...)
if a:0 == 1
echom system('grep -n -i ' . a:1 . ' ~/.fastcd | grep "\[path\]" ' . "| awk -F: '{print $2}' > ~/.fastcd.vim")
elseif a:0 == 2
echom system('grep -n -i ' . a:1 . " ~/.fastcd | awk -F: '{print $2}' > ~/.fastcd.vim")
end
call Pcd()
execute "e ~/.fastcd.vim"
let @/ = '\<'.a:1.'\>'
endfunction
function! Pcd(...)
echom system( "echo " . expand("%:p:h") . "> ~/.fastcd.pwd")
endfunction
function! GoFile(...)
set iskeyword+=.
set iskeyword+=/
let l:WordValue = expand("<cword>")
set iskeyword-=.
set iskeyword-=/
execute "tabnew"
call Fcd(l:WordValue , "fake")
endfunction
function! FindDefine(...)
let l:WordValue = expand("<cword>")
let l:WordFile = expand("%:p")
echom system( "fcd.app search_define " . l:WordValue . " " . l:WordFile . " 5 7 > ~/.fastcd.vim" )
execute "tabnew"
execute "e ~/.fastcd.vim"
let @/ = '\<'.l:WordValue.'\>'
endfunction
" nmap <C-f> <Esc>:call Fcd( expand("<cword>") , 'all' )<CR>
nmap <C-e> <Esc>:call GoFile()<CR>
nmap <C-f> <Esc>:call FindDefine()<CR>
command! -nargs=* Fcd call Fcd( <f-args> )
command! -nargs=* Pcd call Pcd( <f-args> )
" <----------fastcd