Bug 266588 - [VI Mode] Keyboard shortcut for quick save and exit
Summary: [VI Mode] Keyboard shortcut for quick save and exit
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: Vi Input Mode (show other bugs)
Version: unspecified
Platform: Debian stable Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-18 10:28 UTC by Roman Schulz
Modified: 2013-11-29 16:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Keyboard shortcut for quick save and exit - patch. (1.38 KB, patch)
2011-02-26 18:39 UTC, Pranav Ravichandran
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Schulz 2011-02-18 10:28:47 UTC
Version:           unspecified (using KDE 4.4.5) 
OS:                Linux

I would like to use vim shortcuts ZZ (save and exit) and ZQ (exit without save). In vi-compatible mode these shortcuts aren't supported.

Reproducible: Always
Comment 1 Pranav Ravichandran 2011-02-24 17:58:31 UTC
':wq' for 'Save and Exit' ':q' for 'Exit without Saving' work just fine :)
Comment 2 Pranav Ravichandran 2011-02-26 18:39:19 UTC
Created attachment 57539 [details]
Keyboard shortcut for quick save and exit - patch.

ZZ saves the file.
ZQ quits without saving.
Comment 3 Erlend Hamberg 2011-02-27 13:29:00 UTC
Pranav: “:wq” and “:q” do indeed work, but only in the kate application. Your patch while clever doesn't solve the problem. it adds a normal mode command “Z” to kate part which opens the command line – i.e. the same as “:”. This doesn't make much sense and is not Vi[m] compatible. It also adds the commands “:Z” and “:Q” which aren't Vi[m] compatible either.

If the user actually pressed ZZ what would happen is that the commandline would open after the first key press, and the second would type a ‘Z’ in this command line. What should happen is that “ZZ” saves and quits – no command line involved.

In order to achieve this, “ZZ” and “ZQ” should be added as normal mode commands in katevinormalmode.cpp along with all other normal mode commands and code to save and quit should be added there in the kate part.

HOWEVER, there isn't a way for the kate part to request its hosting application to quit. This is work waiting to be done. What should be done is probably to use Qt's signals/slots to send a signal to the hosting application (i.e. Kate app, Kdevelop, Kile, …) which this application can choose to honour. Work on this is very welcome. :-)

(Once this is in place, adding ZZ and ZQ will be very easy. :)
Comment 4 Christoph Cullmann 2012-11-03 15:50:47 UTC
Valid wish, improvements are welcome.
Comment 5 Michal Humpula 2013-11-29 16:47:31 UTC
Git commit 2bcbb2f1024272dea6341f4fcdaef7912b383e3c by Michal Humpula.
Committed on 29/11/2013 at 16:10.
Pushed by michalhumpula into branch 'master'.

vi-mode: add "ZZ" and "ZQ" normal mode commands
REVIEW: 114207

M  +15   -0    part/vimode/katevinormalmode.cpp
M  +3    -0    part/vimode/katevinormalmode.h

http://commits.kde.org/kate/2bcbb2f1024272dea6341f4fcdaef7912b383e3c