Re-learning Vim (1)

Date: 2019/09/17 (initial publish), 2023/04/16 (last update)

Source: en/

Previous Post Top Next Post


I could use Vim as a basic editor with TKL-keyboard while tapping some keys multiple times. This was functional but not so elegant!

I decided to re-learn Vim to use it properly. Here is my learning memo.

For simplicity, I may use ^F to mean CTRL-F.

This page has been updated in 2022 since some basic summary is valid and common to neovim. See Re-learning Vim (4) to get the latest situation. (Modern configuration with which-key.nvim under neovim can allow us not to remember complicated bindings..)


Guiding voice

Here are a few insightful recommendations on the best practices for Vim.

Here, I summarized my rationale behind my configuration decisions for me to remember them.

I follow the voice if Vim Gurus from April 2016 (based probably on Vim version 7.4) as much as possible. Back then, Vimscript was becoming more like a real language but we didn’t have native support to the asynchronously executing background process. Now the asynchronously executing background process offering spell checker, lint, git monitoring, etc. are widely used useful features. Neovim is building on this becoming mature and it use of lua as script language is great.

Please note that I stop customizing vim and migrated to neovim for fancy customization. I only use vim as my backup editor when I suffer issues with my neovim. (My old ~/.vim/ directory implementation is published at . This uses Vim 8 native package management system via ‘packadd!’, git and git submodule.)

For vi, and nvim, neovim is used on my system. (vi is accessed via bash alias)

For vim, vim is used on my system.

I also create bash aliases:

These are handy when Neovim configuration files contain bugs.

(Neovim uses ~/.config/nvim instead of ~/.vim/ for its configuration)


Unlike other editors, the existence of NORMAL MODE is what makes Vim as the great editor which allows the minimum usage of the ALT-key and CTRL-key.

Cheat sheet

Here is my cheat sheet to remind me of all the important key strokes used around NORMAL MODE with emphasis on motion keys (mono space font to see this correctly):

 NORMAL MODE <ESC>:  Goto BOF  gg      r +--- Next Char
 screen                   n N # ?ααα   e / +-- End of Word (non-alnum)
 scroll        ai+wW({[<sp"'`↓  ^B    t / / +- Word Next (non-alnum)
      Change c{motion} cc  c  ^U   n / / / + End of Word (space)
      Delete d{motion} dd  d  H   e / / / / +Word Next (space)
 +--+  Copy   y{motion} yy  y  {  C / / / / / +Till α, x  Delete char
 |zt|  Put After/Before p / P   ( / / / / / / / Find α, r  Replace char
 |^e|  "α  Use α as register    k/ / / / / / /  / EOL,  ~  Change case
 |zz|     0 ^ Fα Tα gE B ge b h M l e w E W tα fα $    gd  Goto definiton
 |^y| ↓↓↓ Split Window ↓↓↓      j --- Line (J for Join line)   ^]  Tag jump
 |zb| ^W + ncsvhjkl=+-_<>|      ) --- Sentence        ^T  Tag jump-back
 +--+                           } --- Paragraph       ^I/^O  Jump next/prev
      Forward Backward Search   L --- Bottom of Page  {visual}>  Indent 
      n N /ααα ?ααα  Find ααα  ^D -- Prev 1/2 Page   {visual}<  Indent 
      n N *    # --- Indicator ^F -- Next Page       {visual}=  Indent 
      , ; tα   Tα -- Till α    /ααα  Find ααα * n N  {visual}gq Format Text
      , ; fα   Fα -- Find α    G --- Goto EOF        J          Join line
   Next Prev   %  -- Match     [{ ]} [[ ]] [] ][ Look for {}
 Record: qα, End-Record: q, Play-Record: , Mark as α: mα, Jump to α: /
 Undo: u, Redo: ^R, Repeat: . , Fold: Open zo/zO/zr/zR, Close zc/zC/zm/zM
 Insert Mode: i/a Before/After Char, I/A Before/After Line, O/o above/below
 Visual Mode: v Char V Line ^V Block, Replace Mode: R, Ex Mode: : or q:

This is intentionally terse. ^ is used as prefix for CTRL-key.

I found some key sequences such as 3w, bc$, ciw, 3yaw, … quite useful, now.

Hints for memorizing key strokes

Since most key assignments are chosen from the initial of the corresponding English word, they are quite intuitive. But, some key assignments look confusing. Here are my hints for memorizing such key strokes.

Interesting commands

Map leader key

I map SPACE-key as leader-key in NORMAL MODE since it has no practical use and easier access than default \-key.

let mapleader = ' '

Some options

I tend to set as follows in the vim startup file (~/.vimrc or its equivalent):

" make vim copy buffer bigger (default 50 lines: viminfo='100,<50,s10,h)
set viminfo='100,<5000,s100,h

" Allow to move cursor beyond for block
set virtualedit=block


INSERT MODE is started from NORMAL MODE by pressing i, I,a,A,o, O, etc.


COMMAND MODE is normally started from NORMAL MODE by pressing : or / or ?.

You can use NORMAL-MODE-like editing for COMMAND MODE situation by starting it with q: or q/ or q?.


Normally, TAB in COMMAND MODE starts wildmenu under :set wildmenu. You can use TAB and S-TAB to chose the one you want.


Use | as in-line command separator.

EMACS/shell-like key sequences

Here are some non-intuitive key sequences used by INSERT MODE and COMMAND MODE and looks like EMACS/Shell sequence.


If you have a task to search some text to make Vim to jump to particular places in its buffer, QUICKFIX MODE is the one to automate your process. No more grep on another terminal window.

There are 4 basic commands to start preparing jump list data.

Then you access and use the jump list from COMMAND MODE.

Please note there are l... variants of above commands.


This is a new Vim/NVim feature. Now capturing shell session is as easy. No more envying EMACS terminal mode.

From TERMINAL-NORMAL MODE, typing i gets you back to TERMINAL MODE.


Don’t run Vim inside TERMINAL-JOB MODE. I ended with ‘buftype’ error. It becomes ’terminal’ type.

Terminal settings

For terminal, set DEL-code(0x7F) for Backspace and use escape sequence for Delete. This frees the ASCII BS (CTRL-H) code so window jump can be mapped to <C-H>.

Previous Post Top Next Post