m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-19 09:03:43 -05:00

Updated Examples (vim) (markdown)

Junegunn Choi
2015-08-09 22:49:37 +09:00
parent 3a21001a48
commit 6b2906b02c

@@ -87,15 +87,47 @@ function! s:all_files()
endfunction
```
### Jump to tags
### Jump to tags (simple)
```vim
command! -bar FZFTags if !empty(tagfiles()) | call fzf#run({
command! -bar Tags if !empty(tagfiles()) | call fzf#run({
\ 'source': "sed '/^\\!/d;s/\t.*//' " . join(tagfiles()) . ' | uniq',
\ 'sink': 'tag',
\ }) | else | echo 'Preparing tags' | call system('ctags -R') | FZFTag | endif
```
### Jump to tags
This version better handles same tags across different files.
```vim
function! s:tags_sink(line)
let parts = split(a:line, '\t\zs')
let excmd = matchstr(parts[2:], '^.*\ze;"\t')
execute 'silent e' parts[1][:-2]
let [magic, &magic] = [&magic, 0]
execute excmd
let &magic = magic
endfunction
function! s:tags()
if empty(tagfiles())
echohl WarningMsg
echom 'Preparing tags'
echohl None
call system('ctags -R --excmd=number')
endif
call fzf#run({
\ 'source': 'cat '.join(map(tagfiles(), 'fnamemodify(v:val, ":S")')),
\ 'options': '+m -d "\t" --with-nth 1,4.. -n 1 --tiebreak=index',
\ 'down': '40%',
\ 'sink': function('s:tags_sink')})
endfunction
command! Tags call s:tags()
```
### Jump to tags in the current buffer
```vim