Why the dot (.) command is so useful in VIM?

Here are some actions that I do with the dot command:

  • Simpler than :%s/\<word\>/replacement/gc is * on the word, then cereplacement<esc> and then repeat n.. This is nice if you have two or three occurrences of your word. If you have several words that you want to replace, then go to the next word, hit * and again n.
  • When I want to left-align some blocks: <Ctrl-V>jjj<..... or insert spaces at the front: <ctrl-v>jjjI<space><esc>....
  • after dd or dw, the dot command will delete another line/word

A magical thing that happens with the dot command is that if it repeats a command that used a numbered register, it will use the next numbered register (see :help redo-register).

Explanation: If you did dd on 9 lines and want to restore them in the order in which you’ve deleted them, then do: "1P......... Note that registers 1 to 9 are Vim’s delete-ring. "1P will insert before the cursor the last deleted text, "2P will then insert prior-to-last deleted text, and so on.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)