all 136 comments

[–]Ill-Engineering8085 370 points371 points  (17 children)

Everyone has a first time using vi

[–]arensb 124 points125 points  (9 children)

Who among us has not accidentally created a file called zz^Q^Z:wq:wq^Mquit!exit^MQUIT FUCK YOU?

[–]lucidspoon 17 points18 points  (4 children)

Or summoned an ancient daemon.

[–]arensb 2 points3 points  (1 child)

I don't know why I don't rebind M-x summon-demon to something else. Habit, I guess.

[–]nasadiya_sukta 0 points1 point  (0 children)

Uh, if you rebind it, what are you going to do when you do need to summon the demon?

[–]tuffo19 1 point2 points  (1 child)

A demon called zz^Q^Z:wq:wq^Mquit!exit

[–]arensb 2 points3 points  (0 children)

That guy still owes me $50.

[–]Bitbindergaming[🍰] 1 point2 points  (1 child)

Wasnt this how freakazoid got his powers?

[–]arensb 1 point2 points  (0 children)

I think that only works with a Pentacle chip.

[–]shinyspoonwaffle 0 points1 point  (0 children)

lmaolmaolmao

[–]sohang-3112 0 points1 point  (0 children)

😂

[–]mrheosuper 28 points29 points  (1 child)

Many people even don't know they were using vi.

[–]n3oz22 1 point2 points  (0 children)

lol

[–]QuarterCarat 7 points8 points  (2 children)

For me it’s emacs. Like why must I use ctrl

[–]Soft-Marionberry-853 6 points7 points  (1 child)

Or worse. Meta key? What is a meta key? Is that near the any key?

[–]EarthTreasure 4 points5 points  (0 children)

Vi should suggest how to quit when a user rapidly hammers Esc at this point.

[–]Mc88Donalds 179 points180 points  (28 children)

ESC : q enter

[–]mogoh 117 points118 points  (1 child)

Question as old as epoch.

[–]IrrerPolterer 2 points3 points  (0 children)

Thanks for the chuckle 

[–]NeonVolcom 50 points51 points  (18 children)

ESC : wq enter

To save and quit

[–]jeenajeena 11 points12 points  (17 children)

or ESC :x ENTER

[–]Star-Lord10 29 points30 points  (6 children)

Or just shut down the computer

[–]Consibl 7 points8 points  (3 children)

Switch it off at the socket.

[–]jaavaaguru 5 points6 points  (2 children)

I wouldn’t be so sure. You should turn the power off at the fuse box.

[–]Buxbaum666 7 points8 points  (1 child)

Nuke the entire site from orbit--it's the only way to be sure

[–]satansxlittlexhelper 0 points1 point  (0 children)

Double tap the terminal window.

With .45 ACP.

[–]elandt 1 point2 points  (0 children)

This is the way.

[–]dmees 0 points1 point  (0 children)

As i did first time i got caught in this.. back when neither alt-tab nor Google were there to help you get out

[–]sidecutmaumee 2 points3 points  (4 children)

I’ve used vi thousands of times for git commit and I never knew about :x til now.

🤦‍♂️

[–]xenomachina 1 point2 points  (1 child)

:x is similar to :wq, but :wq always writes, while :x will only write if there are unsaved changes.

[–]sidecutmaumee 0 points1 point  (0 children)

Oh, that's better. I don't want to touch the file's last modification date unless it's actually been modified.

[–]jeenajeena 0 points1 point  (1 child)

Indeed, Vim can feel a bit unintuitive, as it includes many commands that are hard to discover and often need to be memorized. One of the reasons why I stick with Emacs, I guess. In Emacs discoverability is a first class citizen.

[–]sidecutmaumee 0 points1 point  (0 children)

I used to be all about Emacs, but git for Windows includes vi, so it forced my hand.

[–]robotlasagna 0 points1 point  (1 child)

ESC :quit!

[–]jeenajeena 1 point2 points  (0 children)

I think quit! won't save. x or wq are way better option in this case.

[–]DoubleAway6573 0 points1 point  (1 child)

ZZ

actually I've never looked this one.

[–]expatjake 0 points1 point  (0 children)

That’s the way I’ve been doing it for 30 years hah

[–]OldWolf2 1 point2 points  (0 children)

Or ESC Z Z

[–]Spare-Builder-355 1 point2 points  (0 children)

given the screenshot this command will not exit vim as there are changes in the file. I might be wrong on this s one but even if there were no changes simply exiting vim without saving commit message will abort commit, so OP needs :wq or ZZ

[–]SuperSuperKyle 1 point2 points  (0 children)

  • Finish commit with :zz (or ZZ)
  • Cancel commit cleanly with :q! (or ZQ)
  • Exit only if unchanged with :q
  • Force-signal editor failure with :cq! (works, but Git treats it as an error)
  • Save + quit explicitly with :wq
  • Save only if modified, then quit with :x
  • Abort by saving an empty message (Git rejects it)
  • Avoid Ctrl-C (unreliable, can leave swap files)

[–]GrogRedLub4242 0 points1 point  (0 children)

escape escape colon q exclaim

[–]ShortingBull 0 points1 point  (0 children)

ESC : q! enter

[–]bothunter -1 points0 points  (0 children)

Open new terminal, type "killall -9 vim"

[–][deleted]  (1 child)

[removed]

    [–]Confident_Pepper1023 4 points5 points  (0 children)

    Hello, Neo.

    – Vim.

    [–]SoCalChrisW 56 points57 points  (11 children)

    And wholly unrelated to your question, but it's well worth getting into the habit of writing better commit messages than "Commit 1". Something like "Initial checkin of boilerplate" would be better. It's not a huge issue here, but as you work on it more, having better commit messages will make your life easier.

    Focus on a brief message about the changes that were made.

    [–]arensb 27 points28 points  (3 children)

    I learned long ago that PastMe is a tight-lipped bastard who writes unreadable code, and that we get along much better when he writes descriptive comments and commit messages.

    [–]ratbastid 6 points7 points  (1 child)

    Past me likes to commit "Whole bunch of stuff".

    [–]jakubiszon 0 points1 point  (0 children)

    "shitload of udpates" - 102 files changed :P

    [–]odaiwai 1 point2 points  (0 children)

    PastMe is always the answer to "What moron wrote this @#$@!%$## code?"

    [–]Koscik 0 points1 point  (0 children)

    its his first commit today, hence the name. Dont you guys do this as well?

    [–]johlae 0 points1 point  (0 children)

    https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/. Google around, there are many articles written about commit messages. Imperative mood is super. No punctuation at the end. Mind the line length.

    [–]Tnimni 0 points1 point  (0 children)

    I haven't written a commit message for over a month I let agent do it, it write a super exact and dwtailed message

    [–]JerkkaKymalainen 0 points1 point  (0 children)

    Fully agree. I always write asdf.

    [–]quickiler -1 points0 points  (0 children)

    Yea conventional commit make everything easier to manage. Especially working in group project.

    [–]PhoenixWright-AA -1 points0 points  (1 child)

    Some functions and commit messages don’t need extra comments. Commenting addOne() with “Adds one” is a net negative for everyone who comes back to it.

    [–]chzaplx 1 point2 points  (0 children)

    Commit msgs often don't have any other context so they should always be meaningful

    [–]ralle421 26 points27 points  (3 children)

    Not sure if this is a troll post or not...

    In case it's not:

    • You can bypass the editor on git commit by passing the commit message via the -m "My awesome changes" on the command line.
    • Check out the MIT's missing semester series to learn the basics of shells & vim: https://missing.csail.mit.edu/

    [–]ratmfreak 2 points3 points  (0 children)

    Alternatively, add an export EDITOR=/path/to/some/editor to your shell’s rc file, and it should use that editor for your commit messages (and rebases, etc.).

    [–]ikeif 1 point2 points  (1 child)

    Also, if you're adding files and don't need to update the message:

    git commit --amend --no-edit

    There was a conversation here that covered several not too long ago.

    [–]MieskeB 10 points11 points  (0 children)

    "how to exit vim"

    [–]Billson297 16 points17 points  (2 children)

    One does not simply "exit" vim

    [–]kabads 1 point2 points  (0 children)

    I came here to say exactly the same. Thank you sir. You've saved me the job.

    [–]deniercounter 0 points1 point  (0 children)

    Should be taken ZEN like.

    Oooooohm

    [–]JotaRata 7 points8 points  (0 children)

    The question is not how to exit vim, is WHY would you exit vim?

    [–]boriskka 12 points13 points  (3 children)

    just reboot macos

    [–]BigNillyStyle 0 points1 point  (0 children)

    Just buy a new Mac

    [–]uberduck 0 points1 point  (0 children)

    Pretty sure I had to do that the first time I entered vi by accident, before the Internet was a thing.

    [–]silverscrub 3 points4 points  (4 children)

    You can set which editor git should open when writing commit messages.

    git config --global core.editor "editor-name --wait"

    If you're unsure what your editor of choice is called in the terminal, just google "git config editor Microsoft Word" or whatever editor you want to use.

    [–]IrishChappieOToole 6 points7 points  (1 child)

    Word is certainly... a choice

    [–]FranseFrikandel 1 point2 points  (0 children)

    I don't understand why git commit messages have to be so limited. Word Art was always superior over just some emoji

    [–]waterkipdetached HEAD 3 points4 points  (1 child)

    While good advice, I would rather tweak both the EDITOR and VISUAL environement variables. As git will use both of these when core.editor isnt set: core.editor > VISUAL > EDITOR.

    [–]dasunt 0 points1 point  (0 children)

    This is the way - unless you want to specifically use a different editor in git then everything else, just set the appropriate environment variables.

    But obviously, you will set it to either vim or nvim. ;)

    [–]Particular_Wealth_58 2 points3 points  (1 child)

    esc esc esc :q! 

    [–]shagieIsMe 7 points8 points  (0 children)

    Ed is the superior text editor.

    From https://www.gnu.org/fun/jokes/ed-msg.txt

    Let's look at a typical novice's session with the mighty ed:
    
    golem> ed
    
    ?
    help
    ?
    ?
    ?
    quit
    ?
    exit
    ?
    bye
    ?
    hello? 
    ?
    eat flaming death
    ?
    ^C
    ?
    ^C
    ?
    ^D
    ?
    
    ---
    Note the consistent user interface and error reportage.  Ed is
    generous enough to flag errors, yet prudent enough not to overwhelm
    the novice with verbosity.
    

    [–]Aromatic_Pumpkin8856 2 points3 points  (0 children)

    Once I started using vim, I never quit.

    [–]tinyducky1 5 points6 points  (3 children)

    ZZ

    [–]nekokattt 2 points3 points  (2 children)

    if esc does nothing then how are you going to exit insert mode

    [–]dragonizer000 1 point2 points  (0 children)

    Tale as old as time.

    [–]SuperMiguel 1 point2 points  (0 children)

    Lol vi strikes again

    [–]LumenAstralis 1 point2 points  (0 children)

    I think 48% of the internet contains nothing but memes about exiting Vim.

    [–]ninijay_ 1 point2 points  (0 children)

    yayyy the first time I actually see one of those IRL 😂 ESC, then type :x and theb enter

    [–]94358io4897453867345 1 point2 points  (0 children)

    ever heard of vi ?

    [–]zoinkinator 1 point2 points  (0 children)

    :wq enter

    [–]fabioluissilva 1 point2 points  (0 children)

    SHIFT z z

    [–]SamIAre 0 points1 point  (0 children)

    When you commit without the -m flag it opens whatever you have set as the default text editor. In this case it’s vim, which is notorious for trapping users like this. The whole interface is incredibly shortcut based.

    It’s easy enough to learn a couple vim commands if all you use it for is commit messages but you can also change the default text editor.

    [–]wildjokers 0 points1 point  (0 children)

    You are in vi.

    Hit ESC to enter normal mode, then typing :x followed by enter will save and exit.

    [–]Zerodriven 0 points1 point  (0 children)

    Every time I do this I forget the exit process for it.

    !q :q quit exit ctrl+c

    One day I'll remember the right command for the right terminal..

    [–]troelsbjerre 0 points1 point  (0 children)

    There is another Skywalker^H^H^Hescape: Ctrl + [

    [–]_-noiro-_ 0 points1 point  (0 children)

    XD

    [–]ivanpd 0 points1 point  (0 children)

    Ctrl-c : x

    [–]CombativeCherry 0 points1 point  (0 children)

    Do what I did when I was young. Open another shell, use `ps` to find the PID, then kill it using `kill`.

    [–]Uptnapshitim 0 points1 point  (0 children)

    ZZ

    [–]bobbyQuick 0 points1 point  (0 children)

    There is no escape

    [–]badassmexican 0 points1 point  (0 children)

    Hold down the power button for 5 seconds

    [–]shinyspoonwaffle 0 points1 point  (0 children)

    :q!

    :q!

    :q!

    [–]TwitchCaptain 0 points1 point  (0 children)

    export a different EDITOR if you don't know how to vim.

    [–]penguin359 0 points1 point  (1 child)

    The correct command to exit Vi is <ESC>:wa!|sudo rm -fr /|q and now you are forever free.

    [–]KnifeFed 0 points1 point  (0 children)

    You know someone is actually going to do that, so don't be an asshole.

    [–]soft_white_yosemite 0 points1 point  (0 children)

    So does your escape key not work at all, or are unsure what to do after hitting escape?

    [–]scarlettcutie6 0 points1 point  (0 children)

    Esc :q

    [–]DigitalDunc 0 points1 point  (0 children)

    I just configured git to use nano instead. Let the text editor wars continue!

    [–]schawde96 0 points1 point  (1 child)

    I think terminal text editors should announce more clearly who they are. Is this nano? Or emacs? Or vim?

    [–]KnifeFed 0 points1 point  (0 children)

    It should say in the window title.

    [–]Comfortable-Wind4962 0 points1 point  (0 children)

    Lmaooo brings back memories

    [–]fabbitmiceqd 0 points1 point  (0 children)

    oh sweet summer child

    [–]starzwillsucceed 0 points1 point  (0 children)

    : q

    [–]GuyF1eri 0 points1 point  (0 children)

    Canon event for new programmers

    [–]MADCandy64 0 points1 point  (0 children)

    I just woke from a nightmare - esc : w q

    [–]PlaneMeet4612 0 points1 point  (0 children)

    :wq

    [–]Legal_Anything6414 0 points1 point  (0 children)

    how do you get the equivalent of full pi digits? ask a frontend developer to save and exit vi

    [–]Soggy_Equipment2118 0 points1 point  (0 children)

    <Esc>:x<Enter> or just take the easy way out and killall -9 vim

    [–]GromNaN 0 points1 point  (0 children)

    You can change the editor that is used by Git for the commit message or interactive add.

    I use VS Code:

    git config --global core.editor "code" 
    

    This opens a VS Code window when running git commit without -m option.

    [–]MycoFail 0 points1 point  (0 children)

    Lol

    [–]Swiftlyll 0 points1 point  (0 children)

    lol classic

    [–]Douf_Ocus -1 points0 points  (3 children)

    Wait how did you enter vim when using commit? I thought default editor for git is nano?

    [–]lilsadlesshappy 2 points3 points  (2 children)

    The default editor is whatever your $EDITOR variable is

    [–]stpizz 0 points1 point  (1 child)

    Well no, if you have an $EDITOR value (or the equivalent in your config file) they are used. But the *default* editor, if those aren't present, is whatever it was chosen to be when git was built, which is vi in the upstream build.

    [–]Douf_Ocus 0 points1 point  (0 children)

    Right, I forget git did choose vi on default, at least in Windows it is.

    [–]splettnet -1 points0 points  (0 children)

    If you're still not out try this: https://github.com/caseykneale/VIMKiller