-
Notifications
You must be signed in to change notification settings - Fork 798
Some Facts About Vim
Let’s relax and have some fun now! Here are a few things we've found interesting during development and would like to share with you.
-
There are no such commands as
dd,yy, orcc. For example,ddis not a separate command for deleting the line, but adcommand with admotion.
Wait, but there isn't admotion in Vim! That’s right, and that’s why Vim has a dedicated set of commands for which it checks whether the command equals to motion and if so, it executes_motion instead.
_is an interesting motion that isn't even documented in vi, and it refers to the current line. So, commands likedd,yy, and similar ones are simply translated tod_,y_, etc. Here is the source of this knowledge. -
x,D, and&are not separate commands either. They are synonyms ofdl,d$, and:s\r, respectively. Here is the full list of synonyms. -
You can read a post about how modes work in Vim and IdeaVim.
-
Have you ever used
Uafterdd? Don't even try. -
A lot of variables that refer to visual mode start with two uppercase letters, e.g.
VIsual_active. Some examples. As mentioned here, this was done this way to avoid the clash with X11. -
Other strange things from vi:
- ":3" jumps to line 3
- ":3|..." prints line 3
- ":|" prints current line
-
Vim script doesn't skip white space before comma.
F(a ,b)=> E475. -
Fancy constants for undolevels:
The local value is set to -123456 when the global value is to be used.
-
Vi (not Vim) is a POSIX standard, and has a spec! Vim is mostly POSIX compliant when Vi compatibility is selected with the
'compatible'option, but there are still some differences that can be changed with'copoptions'. The spec is interesting because it documents the behaviour of different commands in a stricter style than the user documentation, describing the current line and column after the command, for example. More details can be found by reading:help posix. -
The Vim documentation contains many easter eggs. We encounter them occasionally, but GitHub user mikesmithgh has compiled a substantial collection here.
- In addition to
:call err_teapot(), which returnsE418: I'm a teapot, there is also:call err_teapot(1), which returnsE503: Coffee is currently not available. Naturally, this is also supported in IdeaVim.
- In addition to
-
Insert mode has all
Ctrlkeys mapped, exceptCtrl-B. In the documentation, it is marked as "CTRL-B in Insert mode gone". Call:h i_CTRL-B-gonein Vim to read whyCtrl-Bwas removed.