How to Get Out of Vi (2015)
liw.fi
liw.fi
If, by any chance, you've entered it accidentally, acknowledge the fortuitous twist of fate you've just witnessed and enjoy the enlightenment that is soon to follow.
Let it give you the warning and then hit :q! if you're really sure.
Also, it's probably better to tell new vi users to write and exit with :w it works just as well and is more consistent.
And :q when just exiting as you mentioned for exactly this reason. Tell me I'm quitting without saving so I can decide what to do next.
I use minicom to communicate with some devices via serial-over-USB - I also tend to suspend my machine while there is still an active connection. When I unsuspend my machine, often my serial connection changes address - and minicom complains that it can't communicate anymore. And here comes the challenge: `ctrl-a q` supposed to quit, but not in this state - it stays unresponsive to all combos I try. I literally smash all keys on my keyboard, and then `ctrl-a q` start working again for some reason.
Maybe `ctrl-smash-everything-78-times` is an easter egg... oh well, I guess I will figure it out one day.
And to be fair, GTK emacs has File->Quit as well (which helpfully reminds you you could use C-x C-c instead!).
This is the number one problem with tech industry. Autists don't understand that people other than them don't spend thousands of hours on what they so happen to be intersted in (for example caring this much about one text editor, when there are literally 1000 other things to learn in operating a computer). While you're at it, explain that you are supposed to press esc then wait 500ms (it's obvious why it works this way if you invest a few hundred hours in studying terminals) then type :q and explain that people born in 2010 are supposed to know what a terminal is even though nobody even used terminals by the late 90s.
In order to quit vim, you have to understand the difference between normal mode and insert mode, and you have to understand the difference between :q and :q!.
If you :q when you wanted to :q!, you're going to get this useless error message:
E37: No write since last change (add ! to override)
But if you don't know about :q!, "(add ! to override)" means nothing. Override what? How do I "add !"??And since you're a total novice, it's likely that you don't even know that you haven't saved your changes to disk yet, so it's not clear to you that "No write since last change" is calling you to :w before :q.
And if you try to explain all that, the user gets pouty. "I just want to quit vim! Why do I have to learn all of this stuff just to stop using it?!?"
Someone should make a safe "get out of any editor" sequence. Kind of like those universal remotes that send all the codes for each button.
This is specifically about neovim, but I've run into the same issue with regular Vim too. I want to install and use packages like NERDTree and maybe an LSP. I do not want to have to install Node for these plugins. If I want to add plugins to neovim, is it pretty much a given I also have to maintain a Node install?
A better suggestion is probably to just hit Esc repeatedly to try to get back to normal mode, and exit via ZZ (save) or ZQ (don't save).
:!bashOf course, that's a tautology.
What? It's flamewardnesday.
(People who love getting hazed and being in cults are then converted into vim users, I guess.)
Anyway, sometimes Git is misconfigured and dumps me into vi. (I use Windows.) When this happens, I just open Task Manager and kill the process. Otherwise, I have no need to learn vi, nor do I think vi is a useful skill to learn.
There is a well-known tutor file that will teach the basic use of vi. On the RedHat 9 family, this is the manual page:
$ rpm -ql vim-common | grep tutor | grep man/man1
/usr/share/man/man1/gvimtutor.1.gz
/usr/share/man/man1/vimtutor.1.gz
Loading Oracle Linux 9 into the WSL subsystem on Windows will bring in this RPM. C:\Users\bofh\>wsl.exe -l -o
The following is a list of valid distributions that can be installed.
The default distribution is denoted by '*'.
Install using 'wsl --install -d <Distro>'.
NAME FRIENDLY NAME
* Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
Ubuntu-22.04 Ubuntu 22.04 LTS
OracleLinux_7_9 Oracle Linux 7.9
OracleLinux_8_7 Oracle Linux 8.7
OracleLinux_9_1 Oracle Linux 9.1
openSUSE-Leap-15.5 openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5
openSUSE-Tumbleweed openSUSE Tumbleweed