To close the quickfix window, you use :cclose
, as @statox mentioned in the comments.
This won't affect which code buffer you're viewing, though. Vim doesn't distinguish between the buffer you were looking at originally and the buffers you navigated to via the quickfix, so to go back you are going to have to use Vim's regular buffer switching commands. If you know the name or number of the original buffer, :b
is probably quickest.
If not, you could try mashing Ctrl-O to jump backwards through the jumplist till you reach the right buffer, or you might want to set up some mappings* (or a plugin) for faster buffer navigation.
If you want something automated, how about adding something like following to your .vimrc?
nnoremap <silent> <leader>gs mA:GscopeFind s <C-R><C-W><cr>
nnoremap <leader>b :cclose<CR>`A
The first mapping adapts your current search mapping to first set an uppercase mark A and then continue with its original behaviour.
The second creates a new mapping that closes the quickfix and then returns to the marked position.
* Make sure you read as far down as the EDIT, because it's after that that the juicy details are included.
:cclose
:h :cclose
? – statox Apr 25 '19 at 9:57:cclose
the command you're looking for? – statox Apr 25 '19 at 11:44