Comments (14)
This is what I have in my .vimrc.
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
Looks like we can now close the issue.
from fzf.vim.
@cj Right, the function signature was changed in b9285c8
So you can now simply do this:
call fzf#vim#tags(expand('<cword>'))
from fzf.vim.
Nice, you can further simplify the code like follows, no need for if-else branch:
call fzf#vim#tags({'options': '-q '.shellescape(expand('<cword>'))})
Note that :Tags
command passes layout option as well.
call fzf#vim#tags({'options': '-q '.shellescape(expand('<cword>')), 'down': '~40%'})
Is there anything else you want to know?
from fzf.vim.
Taking cues from this thread, I mapped over <c-]>
to act like :tjump
to jump to the tag if a single match or open it with FZF otherwise:
function! FzfTagsCurrentWord()
let l:word = expand('<cword>')
let l:list = taglist(l:word)
if len(l:list) == 1
execute ':tag ' . l:word
else
call fzf#vim#tags(l:word)
endif
endfunction
noremap <c-]> :call FzfTagsCurrentWord()<cr>
from fzf.vim.
@junegunn when I try your solution in nvim I get this error
from fzf.vim.
This is pretty awesome! Is there a way to have it show the preview like :Ag
does as well?
EDIT: I found that the following does show a preview :)
nnoremap <silent><Leader>r :Rg <C-R><C-W><CR>
from fzf.vim.
Seems like the plugin is pretty extensible. I got it to work with
fu! FzfTagsCurrWord()
let currWord = expand('<cword>')
if len(currWord) > 0
call fzf#vim#tags({'options': '-q ' . currWord})
else
execute ':Tags'
endif
endfu
from fzf.vim.
Just adding for those preferring to search the current word in :Ag
:
" map <Leader>+F to search in ag the word under the cursor
map <Leader>F :call fzf#vim#ag(expand('<cword>'))<kEnter>
from fzf.vim.
Cool!
Is it possible to do this with :Ag too? Provide the word under cursor or a visual selection?
from fzf.vim.
👍
from fzf.vim.
@junegunn ah, there we go. thank you!
from fzf.vim.
@junegunn : it's beautiful.
from fzf.vim.
Awesome! I stole your version! Why Rg
and not Ag
, though?
Edit: Oh, to use ripgrep
instead of The Silver Searcher, right?
from fzf.vim.
Here's what I ended up with to ripgrep for the token under the cursor (i.e. the whole word, not as a substring of another token):
nnoremap <silent>+ :call fzf#vim#grep(
\ "rg --column --line-number --no-heading --color=always --smart-case -- "
\ . fzf#shellescape('\b'.expand('<cword>').'\b'),
\ fzf#vim#with_preview(), 0)<cr>
(it's too bad there's no fzf#vim#rg
like there is fzf#vim#ag
, that would have made this snippet a lot shorter! As it is, this is copied from the definition of :Rg
, as below)
Line 63 in 1e054c1
from fzf.vim.
Related Issues (20)
- Question: can I change my fzf query with a shortcut
- Feature Request: let preview command highlight line HOT 3
- Getting `;5u` when pressing C-/ to toggle preview
- FZF Popup breaks when you scroll on windows
- How to use Rg to search recent file contents HOT 5
- Feature Request: add a fzf#vim#buffer_grep
- Unable to use commands like :Files and :Buffers HOT 3
- Splits with WinBar change size when opening and closing FZF
- [Feature Request] functional, blocking version of `fzf#run` for neovim HOT 4
- custom fzf_action behaviour have been broken by recent commit HOT 2
- :Helptags perl command failing HOT 11
- "Tab drop" no longer works as fzf action for jumping to existing tab HOT 2
- FZF Preview and Light themes colors not looking ok HOT 7
- Errors when running 'History:' and 'History/' commands HOT 1
- preview.sh not previewing files with nested path on Windows HOT 5
- Ctrl+T/Ctrl+X/Ctrl+V actions don't work correctly in some cases when a swap file exists HOT 4
- How to get fzf.vim to index files at startup? HOT 1
- cursor shape changed from underscore to block in iTerm2 HOT 4
- how to grep through a passed filelist
- Regression/error when running :Tags HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fzf.vim.