0

background

So I have the silver search thing going:

" The Silver Searcher
if executable('ag')
  " Use ag over grep
  let &grepprg = "ag --nogroup --nocolor --ignore wiki --ignore tags"

  " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
  let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'

  " ag is fast enough that CtrlP doesn't need to cache
  let g:ctrlp_use_caching = 0
endif


" bind \ (backward slash) to grep shortcut
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap \ :Ag<SPACE>

when I click on \ I get the prompt to search, which is great, it looks like this: enter image description here

I got three questions:

  1. how do I dismiss the bottom bar? I'm not sure what that action is called.. ideally I would connect that to some keyboard binding

  2. How can i make it so that when i click on a file (or perform some keybinding on a file in the list below).. it automatically jumps to the file AND dismiss the bottom bar?

  3. how can I (with a keyboard shortuct) make the bottom bar higher and smaller? sometimes that's useful when i got tonnes of results

many thanks

  • what do you mean with the bottom bar? – Christian Brabandt Nov 10 '17 at 6:54
  • @ChristianBrabandt just updated the question to answer yours – abbood Nov 10 '17 at 6:55
  • 2
    That is the quickfix list. The one you opened with the :cwindow command. Read the help at :h quickfix to see what commands are available (like e.g. :cclose to close it) – Christian Brabandt Nov 10 '17 at 7:20
  • i see.. that narrows down the search a bit: stackoverflow.com/questions/42217825/… – abbood Nov 10 '17 at 7:50
1

It's called the quickfix window. (See :h quickfix)

  1. It can be dismissed with the command :cclose or with any regular window command. e.g. Ctrl-Wc or Ctrl-Wo.

  2. One way you could do this:

    nnoremap <expr> <CR> &buftype=='quickfix' ? "\<CR>:cclose\<CR>" : "\<CR>"
    

    Another alternative would be to use an autocommand to create a buffer-local mapping only in the quickfix window, or just to use a new trigger for your jump-to-error-and-close mapping. (e.g. <leader><cr>)

  3. You can use the regular window resizing commands:

    • Ctrl-W+
    • Ctrl-W-

    These take counts, so you can resize more rapidly with commands such as:

    • 5Ctrl-W+

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.