Current functionality

When I use <C-P> and <C-Å> I can respectively search file names and contents. Everything works great.

Target functionality

When prepending either with <leader>, I would like to pass the --no-ignore flag to each command (ex. <legend><C-P>).

Here are the relevant parts of my .vimrc

nnoremap <C-P> :Files<CR>
nnoremap <C-Å> :Find<CR>

Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim' " Fuzzy search

let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!{.git,node_modules}/*"' " Enable respecting .gitignore for files
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!{.git,node_modules}/*" --color "always" '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
\         : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),
\ <bang>0)
set grepprg=rg\ --vimgrep
  • 3
    This site is not about others doing the work for you. Tell us what have you tried; where are you struggling?
    – mMontu
    Jun 18 '18 at 12:09

Please note that I changed your mapping to suit my keyboard. However this is what I got in terms of functionality:

nnoremap <C-P> :MyFind0<CR>
nnoremap <Leader><C-P> :MyFind1<CR>
command! -bang -nargs=* MyFind0 call MyFind(0, <q-args>, <bang>0)
command! -bang -nargs=* MyFind1 call MyFind(1, <q-args>, <bang>0)
function! MyFind(numArg, qArg, bangArg)
  let cmd='rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!{.git,node_modules}/*" --color "always" '
  if a:numArg == 1
    let cmd.='--no-ignore '
call fzf#vim#grep(cmd.shellescape(a:qArg), 1,
\ a:bangArg ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
\         : fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'right:50%:hidden', '?'),
\ a:bangArg)
  • I'll check this out tomorrow, thank you for giving it a go!
    – b00t
    Jun 24 '18 at 19:36
  • @b00t So, did it work for you?
    – igorepst
    Jun 27 '18 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.