Live data from Hacker News

How to Exit Vim

github.com

61–70 of 409 posts

Re: How to Exit Vim

#61
Didn't see a mention of a very fast way of exiting Vim, so sharing:

'The iTerm way': map cmd-l to send a hex code '0x6A 0x6B 0x3A 0x71 0x0D' (translates to jk:q, where jk is my Vim binding to get out of insert mode)

For me, just like any other touch typer, left thumb is always on cmd and right ring finger is always on 'l' key, so this arrangement takes least amount of time for me to quit Vim.

Re: How to Exit Vim

#63

- So, how did you learn Vim? I heard there's quite a learning curve. - I just open it, but I couldn't figure out how to quit. Then I have been using it for three years already. (Same applies to Emacs.)

> - So, how did you learn Vim? I heard there's quite a learning curve.

You can go through the interactive vimtutor.

Type :help tutor

Or you can just type :help and find the link to the vimtutor. If you are using gVim, then it should be one of the menu items ( maybe under help? ).

My suggestion is to just search for basic vim cheat sheet if you are getting started. There are also youtube tutorials online. Sometimes watching someone work with vim can help you get over the hump.

> - I just open it, but I couldn't figure out how to quit.

:q to quit.

:q! to quit without saving.

Remember to hit ESC to get back to the normal mode first if you are in other modes.

When you are comfortable with Vim then you can go on to some of the advanced vim topics. Also, in the beginning you might have to ddg/google/etc a bit. Good luck.

Re: How to Exit Vim

#64
Oh dear. What are the chances this will eventually rank fairly highly on search engines - this is going to ruin the soul of the unsuspecting people who end up thinking that this is not satirical advice.

Re: How to Exit Vim

#65

Earlier quoted context omitted.

I live in a different universe to you it seems. The only vim command I know is :q . Honestly, I tried several times over the decades and walked away with my head buzzing. PS: I don't live in emacs either! What I do love in both camps is how the explanations begin... "All you have to do is...[insert irrational (to non-vim/emacs users) command]" which makes me laugh every time. Love the article, which ironically proves…

I know some basic commands and know it well enough to edit git commit messages and interactive rebase (`ddkP` is probably the most advanced command I know). But I've never thought "I prefer this over my regular editor this is amazing". I just don't get the satisfaction. And of course I'd have to dive deep into the ecosystem in order to get the same benefits that my main editor provides out of the box, like idk, cmd+c…

> And of course I'd have to dive deep into the ecosystem in order to get the same benefits that my main editor provides out of the box,

To me, vim shines as a modal editor, not an IDE. I use it for two purpose:

1. quick editing configuration files, or single file scripts 2. an editing mode in an IDE (mostly VSCode)

The main benefit of vim is to save you from using the mouse or the touch pad. I touch type, my indexes rest on F and J, and I can do pretty much anything without leaving the keyboard, without using the arrow keys, and keeping my eyes on the screen. It's not something I'd know how to do without Vim. If I'm using the arrow keys, I need extra-time to relocate the "J" key, which breaks the typing flow.

Re: How to Exit Vim

#66

I have the feeling something is missing on that list, but I can't put my finger on it ...

I think it's the Hulk way. I seriously considered the Hulk way the first time.

(since then I implemented the preemptive way: never ever try to open it again)

Re: How to Exit Vim

#69
As I sit here, vim running for several months inside an nvim terminal inside a tmux window inside an iterm tab inside mac os x, I think the real question is, why exit vim yourself when you can Inception vim's creator to do it for you?

That, as many people know, is actually how vim finally became threaded, and I'm sure it could be used to make a code change that exits vim automatically. Then you only have the task of modifying your vim executable in memory as well as on disk, which is so trivial that I leave it as an exercise to the reader.

Re: How to Exit Vim

#70
post #44

Fun read! My next bash exercise will be to try and understand some of these commands, quite a feat! greping the ps output would work with any program, right ? That was pretty cool. Killing it from emacs was def a good laugh ! They should add the script kiddie way: `sudo rm -rf /` ^^

That might delete the executable but the process would still be running. Yep, `ps | grep` is a common and useful idiom!

In fact "pkill init" or "kill 0" (each with sudo/root privileges executed) will most likely kill all processes and is some kind of process equivalent to delete all files ;-)
Post reply on HN