4 ms·
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
by xp84 3y ago
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)
- lobocinza 3y agoSometimes I don't wan't to save. I may have second thoughts and want to change things before committing.
- davidhaymond 3y agoThat'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.
- sodapopcan 3y agoYa, 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).
- jdougan 3y agoFor 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.
- sodapopcan 3y agoCertainly a fair point!
- FPGAhacker 3y agoI'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).
- sodapopcan 3y agoZZ 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.
- FPGAhacker 3y agoThe worst part is q: is a different command. so if you are trying to :q and miss the colon and try again, you run some other damn f*cking command.
- sodapopcan 3y agoOh I still do that often enough, lol.
- pxeger1 3y agoHuh, I didn’t think of ZQ (to leave an empty commit message) to cancel the commit. I always use :cq (which exits vim with an error status)
- remram 3y agoIf 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.
- samatman 3y agoNo 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.
- xp84 3y agoSomehow 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?)
- worksonmine 3y ago> - 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.
- xp84 3y agoThanks 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?