Broken Q key... how can I leave vim without saving?

49 views
Skip to first unread message

Paolo Bolzoni

unread,
Sep 2, 2020, 4:29:03 AM9/2/20
to vim...@googlegroups.com
Dear list,

It is not a joke, my laptop keyboard is broken and seldom the keys Q,
4, Ins, and few others stop working.
Is there a way to leave vim without saving without using the Q key?

Cheers,
Paolo

tu...@posteo.de

unread,
Sep 2, 2020, 4:41:08 AM9/2/20
to vim...@googlegroups.com
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAO4LoOzFQ-XWB7NfdaMpAfqw%2BTX5FsiKN7VPSTEGj8YUOQXC%3Dw%40mail.gmail.com.
>


Hi Paolo,

From insert mode try:

<ESC>:exit

HTH!

Cheers!
mcc


Jürgen Krämer

unread,
Sep 2, 2020, 4:57:50 AM9/2/20
to vim...@googlegroups.com
Hi

tu...@posteo.de schrieb am 02.09.2020 um 10:40:
> On 09/02 05:28, Paolo Bolzoni wrote:
>>
>> It is not a joke, my laptop keyboard is broken and seldom the keys Q,
>> 4, Ins, and few others stop working.
>> Is there a way to leave vim without saving without using the Q key?
>
> From insert mode try:
>
> <ESC>:exit

this will save changes. One way to quit without saving changes I could
think of is to first reload the buffer and exit then:

:e! | exit

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

meine

unread,
Sep 7, 2020, 2:32:43 AM9/7/20
to vim...@googlegroups.com
ZZ to write the current file if modified and quit

ZQ to quit without checking for changeѕ (like :q!)

Note that those are capitals!

BTW, this tread shows that there are several ways to quit Vim, which
makes it even a bigger laugh when someone is trapped inside ;-)

//meine

meine

unread,
Sep 7, 2020, 2:35:00 AM9/7/20
to vim...@googlegroups.com
> ZQ to quit without checking for changeѕ (like :q!)

Excuses (XQQ), realzed afterwards that your Q-key was broken, so this is
useless...

//meine

Jürgen Krämer

unread,
Sep 7, 2020, 2:47:21 AM9/7/20
to vim...@googlegroups.com
Hi,

Jürgen Krämer schrieb am 02.09.2020 um 10:57:
>
> tu...@posteo.de schrieb am 02.09.2020 um 10:40:
>> On 09/02 05:28, Paolo Bolzoni wrote:
>>>
>>> It is not a joke, my laptop keyboard is broken and seldom the keys Q,
>>> 4, Ins, and few others stop working.
>>> Is there a way to leave vim without saving without using the Q key?
>>
>> From insert mode try:
>>
>> <ESC>:exit
>
> this will save changes. One way to quit without saving changes I could
> think of is to first reload the buffer and exit then:
>
> :e! | exit

or in a lucky moment, when your Q key works, put something like

nnoremap <A-F4> :q<cr>
nnoremap <A-C-F4> :q!<cr>

in your ~/.vimrc. You can do this for the other keys, too, and even
map <F4> to 4, which (to my surprise) even works for entering a count
in front of a normal mode command, e.g., <F4>dd expands to 4dd.

Regards,
Jürgen

Christian Brabandt

unread,
Sep 7, 2020, 3:00:36 AM9/7/20
to vim...@googlegroups.com

On Mo, 07 Sep 2020, 'Jürgen Krämer' via vim_use wrote:

> or in a lucky moment, when your Q key works, put something like
>
> nnoremap <A-F4> :q<cr>
> nnoremap <A-C-F4> :q!<cr>
>
> in your ~/.vimrc. You can do this for the other keys, too, and even
> map <F4> to 4, which (to my surprise) even works for entering a count
> in front of a normal mode command, e.g., <F4>dd expands to 4dd.

Or simply cut and past this into your .vimrc

Best,
Christian
--
Und die Sonne Homers, siehe! Sie lächelt auch uns.
-- Friedrich Schiller

Gary Johnson

unread,
Sep 7, 2020, 11:36:18 AM9/7/20
to vim...@googlegroups.com
On 2020-09-07, Christian Brabandt wrote:
> On Mo, 07 Sep 2020, 'Jürgen Krämer' via vim_use wrote:
>
> > or in a lucky moment, when your Q key works, put something like
> >
> > nnoremap <A-F4> :q<cr>
> > nnoremap <A-C-F4> :q!<cr>
> >
> > in your ~/.vimrc. You can do this for the other keys, too, and even
> > map <F4> to 4, which (to my surprise) even works for entering a count
> > in front of a normal mode command, e.g., <F4>dd expands to 4dd.
>
> Or simply cut and past this into your .vimrc

How about this?

:exe nr2char(113)

or

:exe nr2char(113).'!'

Regards,
Gary

Tim Chase

unread,
Sep 7, 2020, 2:01:11 PM9/7/20
to vim...@googlegroups.com, Paolo Bolzoni
On 2020-09-02 17:28, Paolo Bolzoni wrote:
> It is not a joke, my laptop keyboard is broken and seldom the keys
> Q, 4, Ins, and few others stop working.
> Is there a way to leave vim without saving without using the Q key?

Depends on how desperately you need a "q". You can use

:help :x

which has all the commands in editing.txt that you could need, for
copying into a register and executing. If you need arbitrary letters

:help SOFOTO

gives you a nice rendering of the entire alphabet in both upper- &
lower-case so you can copy/paste from there. Or try

:r !man ascii

to get pretty much every character available. :-)

You can then copy them to build up macros or mappings so you can work
around the mangled key.

That said, I have the same problem (my Z/A/Q/1/Tab column doesn't
work on my daily-driver laptop, so I grabbed an external USB keyboard
for <$10 which pretty much makes it a non-issue for me.

-tim


aro...@vex.net

unread,
Sep 7, 2020, 2:19:50 PM9/7/20
to vim...@googlegroups.com

Assuming the "w" key still works, there's always the "nuke it from orbit"
option; write the file when you're satisfied, (or do nothing, if you don't
want to save anything, then kill the vim process.

Gabriele

unread,
Sep 8, 2020, 12:23:32 PM9/8/20
to vim...@googlegroups.com
On 07/09/2020 17.35, Gary Johnson wrote:
> How about this?
>
> :exe nr2char(113)
>
> or
>
> :exe nr2char(113).'!'

At that point it's easier to do CTRL-V 113 (for the "q"), or CTRL-V 081
(for the "Q"); under Windows you probably need to use CTRL-Q in place of
CTRL-V (:help i_CTRL-V)

Paolo Bolzoni

unread,
Sep 16, 2020, 5:07:13 AM9/16/20
to vim...@googlegroups.com
On Wed, Sep 9, 2020 at 1:23 AM Gabriele <gb...@tiscali.it> wrote:
> At that point it's easier to do CTRL-V 113 (for the "q"), or CTRL-V 081
> (for the "Q"); under Windows you probably need to use CTRL-Q in place of
> CTRL-V (:help i_CTRL-V)

I never thought of using CTRL-v like that! Clever.
Thanks everyone.
Reply all
Reply to author
Forward
0 new messages