Skip to content
Vim Basics: Getting Started with the Terminal Editor

Vim Basics: Getting Started with the Terminal Editor

DodaTech Updated Jun 19, 2026 6 min read

Vim is a modal text editor built for keyboard-only efficiency — once muscle memory forms, you’ll edit text faster than any mouse-driven editor, by keeping your fingers on the home row and using composable commands instead of menus and toolbars.

What You’ll Learn

  • The four Vim modes: Normal, Insert, Visual, and Command-line
  • Essential navigation with h/j/k/l, words, and line jumps
  • Editing commands: delete, yank, paste, undo, replace
  • Search, substitution, and global commands
  • Basic .vimrc configuration and plugin management with vim-plug

Why Vim Basics Matter

Vim is installed on practically every Unix-like system. When you SSH into a server, edit a config file, or work on a remote machine, Vim is there. Even if your daily editor is VS Code, knowing Vim basics means you’re never helpless on a bare terminal.

Durga Antivirus Pro uses Vim for on-server configuration editing and quick log file analysis during incident response.

Learning Path

    flowchart LR
  A[Terminal Basics] --> B[Vim Modes<br/>You are here]
  B --> C[Navigation & Editing]
  C --> D[Search & Substitution]
  D --> E[.vimrc & Plugins]
  E --> F[Productive Vim Workflow]
  style B fill:#f90,color:#fff
  

Understanding Vim Modes

Vim’s defining feature is modal editing — the keyboard does different things depending on the current mode.

ModeHow to EnterWhat It’s For
NormalEscNavigation, copying, deleting, undoing
Inserti, a, oTyping text
Visualv, V, Ctrl+vSelecting text by character, line, or block
Command-line:Running commands like save, quit, search

Most beginners get confused because they try to type while in Normal mode — the letters become commands, not text. Press i to enter Insert mode first.

Essential Navigation

Keep your hands on the home row. Never reach for arrow keys:

KeyMovement
hLeft one character
jDown one line
kUp one line
lRight one character
wForward one word
bBackward one word
eEnd of current word
0Beginning of line
$End of line
ggFirst line of file
GLast line of file
:42Go to line 42

Numbers prefix moves: 3w moves forward 3 words, 5j moves down 5 lines.

Editing Commands

CommandEffect
xDelete character under cursor
ddDelete (cut) current line
dwDelete from cursor to end of word
d$Delete from cursor to end of line
yyYank (copy) current line
pPaste after cursor
PPaste before cursor
uUndo
Ctrl+rRedo
.Repeat last change
rReplace single character

Combine commands with motions: d3w deletes three words, y2j yanks two lines (current and below).

Search and Substitution

/pattern     " Search forward for 'pattern'
?pattern     " Search backward
n            " Repeat search forward
N            " Repeat search backward

:%s/old/new/g    " Replace all 'old' with 'new' in file
:%s/old/new/gc   " Same, but ask for confirmation each time
:5,15s/old/new/g " Replace only between lines 5-15

Example: Convert snake_case to camelCase

Before:
user_name, account_id, created_at

After running: :%s/_\(.\)/\U\1/g
userName, accountId, createdAt

Basic .vimrc Configuration

Your .vimrc file (~/.vimrc) configures Vim’s behavior:

" Essential settings
set nocompatible
syntax on
filetype plugin indent on
set number
set relativenumber
set tabstop=2
set shiftwidth=2
set expandtab
set mouse=a
set clipboard=unnamedplus
set hlsearch
set incsearch
set ignorecase
set smartcase

" Leader key (space)
let mapleader = " "

" Quick save and quit
nnoremap <Leader>w :w<CR>
nnoremap <Leader>q :q<CR>
nnoremap <Leader>wq :wq<CR>

" Clear search highlight
nnoremap <Leader>h :nohlsearch<CR>

" Buffer navigation
nnoremap <Leader>n :bnext<CR>
nnoremap <Leader>p :bprev<CR>

" Split navigation
nnoremap <Leader>h <C-w>h
nnoremap <Leader>j <C-w>j
nnoremap <Leader>k <C-w>k
nnoremap <Leader>l <C-w>l

Plugins with vim-plug

Install vim-plug:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Add to .vimrc:

call plug#begin()

Plug 'preservim/nerdtree'            " File explorer
Plug 'tpope/vim-fugitive'            " Git integration
Plug 'vim-airline/vim-airline'        " Status line
Plug 'sheerun/vim-polyglot'           " Language support
Plug 'junegunn/fzf.vim'               " Fuzzy file finder
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Code completion

call plug#end()

Inside Vim, run :PlugInstall to download and install all plugins.

Common Errors

1. Forgetting Which Mode You’re In

Typing dd in Insert mode literally types the letters “dd”. Press Esc to ensure you’re in Normal mode before using commands.

2. Hitting Ctrl+S

Ctrl+S freezes terminal output. Unfreeze with Ctrl+Q. Avoid this key combination in Vim.

3. Not Saving Before Quitting

:q fails with E37: No write since last change. Use :wq to save and quit, or :q! to force quit without saving.

4. Arrow Key Dependency

Arrow keys in Insert mode work, but they break the home-row efficiency that makes Vim fast. Disable them temporarily to force learning:

inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>

5. Buffer Confusion

Opening many files creates many buffers. Use :ls to list them, :b3 to switch to buffer 3, :bd to close the current buffer.

6. Plugin Not Found

:PlugInstall fails if plug.vim isn’t installed. Run the curl command again. Ensure your .vimrc has call plug#begin() and call plug#end() in the right places.

7. Indentation Wrong for Python

Add this to .vimrc for Python files:

au BufRead,BufNewFile *.py set tabstop=4 shiftwidth=4 expandtab

Practice Questions

  1. What are the four modes in Vim? Normal, Insert, Visual, and Command-line.

  2. How do you move down 10 lines in Vim? 10j — the number prefixes the motion.

  3. How do you yank (copy) the current line? yy in Normal mode. Paste with p.

  4. What is the substitution command to replace all ‘foo’ with ‘bar’? :%s/foo/bar/g

  5. What does set relativenumber do? Shows line numbers relative to the cursor position, making 5j and 12dd easier.

Challenge: Create a .vimrc from scratch (no copy-pasting). Include: line numbers, tab settings, leader key mappings for save/quit, a file explorer plugin, and a fuzzy finder. Use it for one week without a mouse.

FAQ

How long does it take to learn Vim basics?
About 2-4 hours to learn the modes and basic navigation. About 2 weeks of daily use to become faster than a GUI editor.
Should I learn Vim or Neovim?
Start with Vim. Neovim is a modern fork with better plugin architecture. You can switch later — the core commands are identical.
Can I use Vim for large projects?
Yes. Vim handles files of any size. Plugins like coc.nvim provide LSP-based autocompletion similar to VS Code.
How do I exit Vim?
:q to quit. :wq to save and quit. :q! to quit without saving. ZZ to save and quit from Normal mode.
What is vimtutor?
An interactive tutorial built into Vim. Run vimtutor from the terminal — it takes about 30 minutes and teaches all the basics.

What’s Next

TutorialWhat You’ll Learn
Neovim Setup GuideModern Vim with Lua configuration and LSP
VS Code GuideGUI editor with Vim emulation extension
Linux Administration BasicsManaging servers where Vim is your only editor

Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro. Updated 2026-06-19.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro