Skip to content

Vim Shortcuts for CKA

In the CKA exam, you don't have VS Code. You have a terminal and vim. Speed is your only friend. Mastering these specific keystrokes will save you ~10 minutes, which is enough time to answer 2 extra questions.

1. The "Setup" (.vimrc)

Before you start the exam, run this instantly. It fixes the terrible default indentation behavior when pasting YAML.

bash
echo "set expandtab" >> ~/.vimrc
echo "set tabstop=2" >> ~/.vimrc
echo "set shiftwidth=2" >> ~/.vimrc
echo "set autoindent" >> ~/.vimrc

2. Navigation (Movement)

Stop pressing j twenty times.

  • G : Go to Bottom of file.
  • gg : Go to Top of file.
  • $ : Go to End of line.
  • 0 : Go to Start of line.
  • w / b : Jump forward/backward by Word.
  • 50G : Go to line 50 (useful when error log says "error on line 50").

3. Editing (Action Mode)

  • o : Open new line BELOW cursor and enter Insert mode.
  • O : Open new line ABOVE cursor.
  • dd : Delete (Cut) current line.
  • 5dd : Delete 5 lines.
  • u : Undo. (The most important key).
  • Ctrl + r : Redo.

4. Bulk Actions (YAML Editing)

Deleting a whole block of "status" fields in a copied YAML:

  1. Move cursor to start of block.
  2. Press V (Shift+v) for Visual Line Mode.
  3. Press j to select lines down.
  4. Press d to delete.

5. Indenting Blocks (The YAML Fixer)

  1. V select the lines.
  2. > to indent right (add 2 spaces).
  3. < to indent left (remove 2 spaces).