2

I am trying to map Ctrl + q to quit editing the file. I added the below line to my .vimrc

 nnoremap <C-q> :execute "q"<CR>

On pressing the above key combination, nothing happens, vim doesn't quit. No Error, no message.

Can you please help me figure out what is wrong with this setting?

EDIT: My vimrc file is https://gist.github.com/mdtareque/9d28c7b63b2b77d15679374a8dfbad20

I see no effect of pressing <C-q>, probably something is conflicting with existing setup/plugins. Above is my vimrc, almost all settings are being used.

Output of verbose map <C-q> is Last set from ~/.vimrc

FYI. I am on ubuntu 15.10, and

$ vim -version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 21 2015 12:30:04)
11
  • 2
    Works for me. What does :verbose map <c-q> tell you?
    – Antony
    Commented Jun 23, 2016 at 20:19
  • @Antony it says 'Last set from ~/.vimrc'. Also added link to my vimrc file
    – mtk
    Commented Jun 23, 2016 at 21:23
  • When I do :verbose map <C-q> I get n <C-Q> * :q<CR> and then on the next line it says "Last set from ~_vimrc." What does the first line say for you?
    – Tumbler41
    Commented Jun 23, 2016 at 21:33
  • @Tumbler sorry I didn't see that properly. The first line says n <C-Q> * :q<CR>
    – mtk
    Commented Jun 23, 2016 at 21:41
  • 2
    <C-q> is a special mapping interpreted by the terminal meaning "continue output" (<C-s> is "stop output"). The solution is the same as in the duplicate target. Commented Jun 23, 2016 at 22:01

1 Answer 1

4

Why do you need the call to execute? This should work just fine:

nnoremap <C-q> :q<CR>

Of course if your file has been edited vim will give you a warning and won't quit.

1
  • No effect still, I have added my complete vimrc, please can you take a look. Seems something is conflicting.
    – mtk
    Commented Jun 23, 2016 at 21:27

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