Skip to content

Some Facts About Vim

IdeaVim Bot edited this page Jan 20, 2025 · 1 revision

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, or cc. For example, dd is not a separate command for deleting the line, but a d command with a d motion.
    Wait, but there isn't a d motion 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 like dd, yy, and similar ones are simply translated to d_, y_, etc. Here is the source of this knowledge.

  • x, D, and & are not separate commands either. They are synonyms of dl, 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 U after dd? 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.

Clone this wiki locally