Home/Engineer/Linux / Shell/Vim Practical Guide — Using …
Linux / ShellBeginnerUbuntuDebianCentOSmacOSvimlinux

Vim Practical Guide — Using Vim at Work Without Plugins

Covers mode switching, motions, visual block, macros, and multi-file editing so you can use Vim on the job immediately—no plugins required.

Contents
  1. Mode Switching
  2. Cursor Movement (Normal mode)
  3. Editing Commands
  4. Search and Replace
  5. Visual Block (Ctrl+v)
  6. Recording Macros
  7. Multi-file Editing
  8. Useful Settings (~/.vimrc)

Mode Switching

KeyAction
iInsert before cursor
aInsert after cursor
oOpen a new line below
OOpen a new line above
EscReturn to Normal mode
vVisual mode
VVisual Line mode
Ctrl+vVisual Block mode
:Command-line mode

Cursor Movement (Normal mode)

CODE
h j k l       ← ↓ ↑ →
w / b         next/previous word start
e             end of word
0 / $         start/end of line
gg / G        start/end of file
50G           go to line 50
Ctrl+f / b    page down/up
%             jump to matching bracket

Editing Commands

CODE
dd            delete current line (cut)
5dd           delete 5 lines
yy            yank (copy) current line
5yy           yank 5 lines
p / P         paste (below/above)
u             undo
Ctrl+r        redo
x             delete character under cursor
dw            delete word
cw            change word (delete then insert mode)
.             repeat last command

Search and Replace

VIM
/pattern        search downward
?pattern        search upward
n / N           next/previous match
*               search word under cursor

" replace all
:%s/old/new/g

" replace with confirmation
:%s/old/new/gc

" specific range (lines 10–20)
:10,20s/old/new/g

" ignore case
:%s/old/new/gi

Visual Block (Ctrl+v)

Useful when you need to edit multiple lines at once.

  1. Enter Visual Block mode with Ctrl+v
  2. Select the range with j/k
  3. I → type text → Esc : insert at the start of each line
  4. d : delete the block
  5. > / < : indent / unindent

Recording Macros

CODE
qa        start recording into register 'a'
...       perform edits
q         stop recording
@a        play the macro
10@a      play 10 times
@@        replay last macro

Multi-file Editing

VIM
:e file.txt           open a file
:sp file.txt          horizontal split
:vsp file.txt         vertical split
Ctrl+w w              switch split windows
Ctrl+w =              equalize window sizes

:tabnew file.txt      open in a new tab
gt / gT               next/previous tab
:tabn 2               go to tab 2

:buffers              list open buffers
:b2                   switch to buffer 2

Useful Settings (~/.vimrc)

VIM
set number            " line numbers
set relativenumber    " relative line numbers
set tabstop=2         " tab width
set expandtab         " use spaces for tabs
set autoindent
set hlsearch          " highlight search
set incsearch         " incremental search
set ignorecase
set smartcase
syntax on
colorscheme desert
#vim#linux
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Topic-related official docs (auto-linked · not per-claim sources)Linux man pages ↗

Questions & answers

Ask a question about this guide. We'll review and reply.