type
Post
status
Published
date
Aug 3, 2025
slug
summary
I want to make it short, but Vim is too powerful
tags
Tool
Vim
category
Tech notes
icon
password
 
🔔
Prelude: Yes, You can always type :h to see help, for example, :h windows

Vim in not so short

Preliminaries

  • When vim is not available, you can temporarily use cat or nano as alternatives
  • When using a new IDE, you should first learn or configure:
    • save
    • copy / paste
    • duplicate line
    • delete word / delete line
    • line movement
    • navigate forward / back
    • undo / redo
    • page navigation (page down, page up, center to middle, etc.)
    • indent / unindent
    • multi-cursor
    • search / content search
    • input commands (Ctrl + P in VSCode, double Shift in IntelliJ, : in vim…)
    • completion, suggestion, parameter hint, hover hint
    • go to / peek definition, type, declaration, reference, implementation
    • rename symbol / refactor (if available)
    • AI controlling: toggle chat box, trigger inline chat…
    • tabs / windows management
  • Use the :help command to query anything you don’t understand
  • :set option? can view current settings

Windows and Tabs

Buffer: Can be understood as a temporary file. Even if this file is edited, it doesn’t mean it’s written to the actual file. We can observe buffers through windows and manage them through tabs.
  1. Use commands starting with b in Ex (command line) mode for buffer operations:
      • bd buffer delete; bwipeout clears more thoroughly
      • bn or bnext switch to next buffer
      • bp or bprevious switch to previous buffer
      • ctrl + ^ switch to the last buffer
 
Ctrl + W window shortcuts and :sp split commands are the basics of window management. :sp can use parameters to specify files to split (open a new window for this file)
  1. Ctrl + W + w cycle windows, Ctrl + W + hjkl switch focus left/down/up/right (move cursor)
  1. Ctrl + W + = (make window panes equal size)
  1. Ctrl + W + + Ctrl + W + Ctrl + W + < Ctrl + W + > (fine-tune window size)
  1. :vsp performs vertical split, dividing into two sides
  1. :resize 20 sets height to 20 lines; :vertical resize 80 sets width to 80 columns
 
:tabs is the basic tab management command.
  1. :tabnew opens a new tab, :tabe (edit) opens a tab for editing. Can be followed by filename.
  1. :tabn :tabp switch tabs, or use gt gT to switch
  1. Display current buffer in new tab: :tab split
  1. :tabmove move tab, for example :tabmove 2
  1. Batch execution:
      • :tabdo {cmd} execute on all tabs, e.g., :tabdo set nocursorline
      • :windo {cmd} execute on each window in current tab, e.g., :windo diffthis
 
:only and :close are universal management methods
  1. Type :close :only directly to manage windows
  1. Type :tabclose :tabonly to manage tabs

Key Remapping

Here’s the key remapping configuration in VSCode vim extension:
Common key aliases:
  • <Backspace>
  • <C-c> -> Ctrl + C
  • <A-c> -> Alt + C
  • <Shift>
  • <CapsLock>
  • <Tab>
  • <Enter>
  • <Esc>
  • <Cmd-> Mac specific
  • <Up>
  • <Down>
  • <Left>
  • <Right>

vim Configuration File

Use the .vimrc file in the home directory:

Unbound Keys

In VSCode and other IDEs, you can return Vim-controlled keys to the IDE, since they have no use in GUI interfaces.
  • Ctrl + D scroll down
  • Ctrl + Z suspend Vim
  • Ctrl + X decrease number at cursor by 1, in insert mode it’s completion, decrease by 1 is quite useful
  • Ctrl + C can be considered
  • Ctrl + F scroll forward, in insert mode used to view command history
  • Ctrl + W window command, delete one word before cursor
  • Ctrl + P completion
  • Ctrl + S pause output
  • Ctrl + Q same as Ctrl + V, only q alone is for recording macros, VSCode defaults to Add cursor below, multi-cursor editing tool
  • Ctrl + Y / E scroll window up/down by 1 line
  • Ctrl + T depends on situation

Quick Reference

(jut for memory, may not be accurate)
  1. w -> word
  1. b -> back
  1. e -> end
  1. H -> page head; L -> low; M -> middle
  1. zz move current line to the middle position
  1. Ctrl + U & Ctrl + D half screen move up & down
    Result and Option in shortGolang in short
    Loading...