Mastering Vim: Most Used Tips and Tricks for Faster Editing

Unlock the full power of Vim with these essential tips and tricks used by pros. Learn how to move faster, edit smarter, and customize your workflow like a true power user.

Mastering Vim: Most Used Tips and Tricks for Faster Editing
Photo by Lukas / Unsplash

Vim is powerful. But it only becomes magical when you go beyond :wq and i. This guide delivers practical, high-impact Vim tips and tricks used daily by pros β€” from navigation to editing, clipboard magic to plugins. Whether you're writing code or editing configs, these will make you faster and happier.

🧠 TL;DR

Here are the most-used Vim tips and tricks to supercharge your editing:

  • Use hjkl to navigate, w/b to move by words.
  • Yank and paste with yy, dd, p.
  • Visual select with v, V, or Ctrl+v.
  • Use macros (q, @) to automate actions.
  • Navigate files with :e, :bnext, :ls.
  • Split windows: :vsp, :sp, Ctrl+w combos.
  • Search and replace with :%s/old/new/g.
  • Save time with plugins and .vimrc settings.

πŸ”§ Mastering Vim: Most Used Tips and Tricks

Vim is a powerful, lightweight text editor built into every Unix-like system. Mastering it not only boosts your productivity but also helps you stay efficient on remote systems where GUI editors aren’t available.

Here’s a breakdown of the most practical and frequently used tips, broken into categories for easier learning.


πŸ•ΉοΈ Movement & Navigation

Basic motion:

  • h β†’ left
  • l β†’ right
  • j β†’ down
  • k β†’ up

Word-based motion:

  • w β†’ next word
  • b β†’ previous word
  • e β†’ end of word

Line & file motion:

  • 0 β†’ beginning of line
  • ^ β†’ first non-blank character
  • $ β†’ end of line
  • gg β†’ beginning of file
  • G β†’ end of file
  • :n β†’ go to line n

βœ‚οΈ Copy, Paste, Delete

Yank (copy):

  • yy β†’ yank entire line
  • yw β†’ yank word
  • y$ β†’ yank to end of line

Paste:

  • p β†’ after cursor
  • P β†’ before cursor

Delete:

  • dd β†’ delete line
  • dw β†’ delete word
  • d$ β†’ delete to end of line

πŸ“¦ Visual Mode

Visual selection is powerful:

  • v β†’ character-wise selection
  • V β†’ line-wise selection
  • Ctrl+v β†’ block (column) selection

Once selected, you can d to delete, y to yank, > or < to indent, and r<char> to replace all characters.


πŸ”„ Search & Replace

To search:

:/pattern

To search and replace globally:

:%s/old/new/g

With confirmation:

:%s/old/new/gc

πŸͺ„ Macros (Repeat Actions)

Start recording with:

q<register>  " e.g. qa

Do your edits, then stop recording with q.

Replay with:

@<register>  " e.g. @a

Repeat multiple times:

10@a

πŸͺŸ Window Splits & Buffers

Splits:

:vsp filename   " vertical split
:sp filename    " horizontal split

Window navigation:

  • Ctrl+w h/j/k/l β†’ move between splits
  • Ctrl+w = β†’ equal size

Buffers:

:ls            " list open buffers
:bn / :bp      " next/previous buffer
:bd            " delete buffer
:e filename    " open new file

βš™οΈ Customization (~/.vimrc)

Use vim ~/.vimrc to configure settings.

Example:

set number          " Show line numbers
syntax on           " Enable syntax highlighting
set tabstop=4       " Tab width
set expandtab       " Use spaces instead of tabs
set autoindent      " Smart indentation

πŸ”Œ Plugins (Bonus)

Use vim-plug to install plugins.

Example ~/.vimrc snippet:

call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'
Plug 'tpope/vim-commentary'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
call plug#end()

Then open Vim and run:

:PlugInstall

πŸ“ Create/Edit Files with Vim

Create a new file:

vim myfile.txt

Edit /etc/hosts (as root):

sudo vim /etc/hosts

🧼 Clean Exit

Save and quit:

:wq

or , save one keystroke !

:x

Quit without saving:

:q!

Save without quitting:

:w

βœ… Final Tips

  • Practice! Use Vim for daily tasks to develop muscle memory.
  • Use :help <command> when stuck.
  • Always backup your .vimrc.

Happy Vimming !