Version: unspecified (using KDE 4.4.5)
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.
':wq' for 'Save and Exit' ':q' for 'Exit without Saving' work just fine :)
Created attachment 57539 [details]
Keyboard shortcut for quick save and exit - patch.
ZZ saves the file.
ZQ quits without saving.
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. :)
Valid wish, improvements are welcome.
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
M +15 -0 part/vimode/katevinormalmode.cpp
M +3 -0 part/vimode/katevinormalmode.h