At the risk of angering all the vim-heads (this tip isn’t for anyone who likes vim or even emacs):
editor = "nano -t"
This nano option is aka --saveonexit
Things accomplished:
- avoids using an overpowered modal editor that requires several keystrokes just to save and quit when done writing my couple of sentence commit message
- avoid even having to tell it I want to save. Of course I want to save. ^x - all done
(In the unlikely event you decide you want to abort the commit, just hit ^k a few times to kill the text and then ^x)
(Edit: Updated to the default exit keybinding which is ^x)
> - avoids using an overpowered modal editor that requires several keystrokes just to save and quit when done writing my couple of sentence commit message
Funny, I find I do way less keystrokes in modal editors. I feel handicapped without. My patience runs out as soon as I have to use the arrows to fix something a few words back.
> - avoid even having to tell it I want to save. Of course I want to save. ^x - all done
ZZ and ZQ isn't very difficult. And shift is usually easier on the pinky than ctrl.
You don't have to like vim, that's ok, but there's no need to exaggerate when comparing. When I was new I was so terrified of getting stuck in vim that I learned to use the `-m` option in all my commits. I still use it, but with vim keys even in my shell because it's so useful.
Thanks for your reply. I wanted to clarify because of these 2 statements:
> I do way less keystrokes in modal editors. I feel handicapped without. My patience runs out as soon as I have to use the arrows to fix something a few words back.
nano and micro do support lots of types of cursor movement (the same ^a and ^e emacs bindings that work across the mac os work fine, for instance. They also have word-forward and word-back) without resorting to hammering the arrow keys. And mouse support too, for the times when that makes more sense. And all of this without having modes, and with most of the bindings visible on screen (which there is more than enough room for in modern usage so I'm a big fan of that).
> ZZ and ZQ isn't very difficult.
Keeping track of what mode you're in is the primary reason it doesn't speak to me, is all. I haven't met many people (anecdotal disclaimer!!) who actually use vim by choice, compared to how many young developers I've met who seem to have been told they have to use it when using the Terminal, so they subsequently wrote down "ESC, :wq" on a sticky note, and get flummoxed if they accidentally do something wrong because they have no idea how to use it. I saw these developers actually shying away from using things like git cli -- they became afraid of editing text in a terminal due to the unforgiving vim learning curve.*
Of course, I also agree you don't have to dislike vim and am glad your expertness with it makes you more productive. I've seen several developers who have mastered vim zipping around multiple documents and who knows what, with great efficiency. (While I don't feel like I'm missing anything by using a GUI app for such tasks, I'm still very impressed by those people!) I just want you to know I don't dislike vim completely irrationally :)
* As an example, this very thread has about 5 vim experts who didn't even know about your neat ZZ and ZQ trick! If lots of pros don't even use vim as effectively as it's designed to be used, what hope do new users have?
> And all of this without having modes, and with most of the bindings visible on screen
> Keeping track of what mode you're in is the primary reason it doesn't speak to me, is all.
Both vim and neovim has the mode on the bottom unless you're in normal. I first started using vim to get away from electron apps eating my ram. But it clicked pretty quick and fixed my RSI among other things. Modal editing is underrated.
That's a nifty option! In (neo)vim, I like to use the ZZ keybinding to quickly save if modified and then quit. If I want to abort the commit, I'll type ZQ to discard changes and quit.
Ya, it's somewhat surprising that ZZ isn't the binding that is burned into people's minds instead of :wq<cr>. I've even met regular vim users who don't know ZZ which, to be a bit hyperbolic, is mindboggling.
EDIT: And of course there is vim -y to make vim behave more like a "normal" editor than even nano :D (ie, you get ctrl-s and ctrl-q).
For me, it's because when I learned BSD 4.2 vi in the mid-80s the emphasis was on learning the decomposed commands then building up. If you learned w and q , wq is obvious and non-magical.
I've been using vi variants for decades and didn't know ZZ or ZQ. This solves a major pain point for me (mis-typing :q, trying again, now I'm off in the weeds).
ZZ is particularly nice since it sorta "does the right thing" in that if you have an unwritten empty buffer, it will silently discard it and quit. I guess I haven't really run into this as I was taught ZZ from the beginning but I imagine hitting :wq<cr> on such a buffer is pretty annoying.
If you are in `git commit --amend` or am/rebase/cherry-pick, the message did not start empty, and using ZQ will proceed with committing. :cq is a good idea.
No one's going to make you use vim, don't worry. But I don't find ^x vs jk:x compelling as a reason not to. Nor the difference between opening instantly (nano) vs. opening instantly (neovim). But I might :q! out of more commits than you do, who knows.
I used nano for about five years for git commits before I decided to embrace the Vim Way. No need to feel defensive about it, it's there for a reason.
Somehow I knew there would be a half dozen members of the vim brotherhood out to defend it against a perceived lack of reverence for it.
<edited to remove pointless debate> To the rest of us, it boils down to "learn vim so you can prove you are a Real Hacker."
I acknowledge that knowing a thing I don't know (how to use vim to do anything useful) technically makes you smarter than me in the sense of 'possessing more knowledge about vim.' So, good for you. On the other hand, I don't accept that that knowledge is more useful than the knowledge of how to use literally any other good program that edits text. And I don't think anything should be that obtuse and seemingly intentionally non-obvious (onscreen visibility of important bindings or commands would aid in learning, and could be turned off by the true elite such as yourself, couldn't they?)
Things accomplished:
- avoids using an overpowered modal editor that requires several keystrokes just to save and quit when done writing my couple of sentence commit message
- avoid even having to tell it I want to save. Of course I want to save. ^x - all done
(In the unlikely event you decide you want to abort the commit, just hit ^k a few times to kill the text and then ^x)
(Edit: Updated to the default exit keybinding which is ^x)