Fzf: [Question] Detect if the terminal buffer is used by fzf or not in neovim

Created on 22 May 2016  路  3Comments  路  Source: junegunn/fzf

  • Category

    • [x] Neovim

  • OS

    • [x] Mac OS X

  • Shell

    • [x] zsh

I'd like to add this tnoremap <esc> <c-\><c-n> to my .vimrc but the problem is that it breaks the ESC with fzf. So is there is any way I can check if the terminal buffer is related to fzf or not and then decide to apply this key binding to it or not?

neovim question

Most helpful comment

tnoremap <expr> <esc> &filetype == 'fzf' ? "\<esc>" : "\<c-\>\<c-n>"

FYI, you can use CTRL-C instead of ESC to close fzf.

All 3 comments

tnoremap <expr> <esc> &filetype == 'fzf' ? "\<esc>" : "\<c-\>\<c-n>"

FYI, you can use CTRL-C instead of ESC to close fzf.

@junegunn Thanks!

I know about CTRL+C but it's just that my brain is programmed to use ESC for exit while CTRL+C is for killing processes :)

For the record, I just came with this solution:

tnoremap <Esc> <C-\><C-n>
au TermOpen term://*fzf* tnoremap <buffer> <Esc> <Esc>

Note that tunmap does not work. I also have to use the double wildcard in *fzf*.

In any case, junegunn's solution is better tmo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alistaircolling picture alistaircolling  路  3Comments

leonklingele picture leonklingele  路  3Comments

chrisamow picture chrisamow  路  3Comments

lbeier picture lbeier  路  3Comments

ghost picture ghost  路  3Comments