Fundamentals 6 min read

7 Practical Vim Tricks to Boost Your Productivity

This guide presents seven actionable Vim techniques—including leader key mapping, navigation shortcuts, Git integration, and powerful substitution commands—to help users work faster and more efficiently in everyday editing tasks.

ITPUB
ITPUB
ITPUB
7 Practical Vim Tricks to Boost Your Productivity

Vim is a highly efficient editor, but beginners often miss its productivity potential. This tutorial introduces seven practical Vim tricks that serve as an entry‑level guide for improving workflow.

1. Customize the leader key

Map a convenient leader key (e.g., ,) in .vimrc to shorten command sequences. Example mapping lets you press ,jj to exit insert mode and use ,j for visual line selection.

2. Essential navigation shortcuts

h j k l

– move left, down, up, right; prefix with a number to repeat (e.g., 3j). ^ – jump to line start. $ – jump to line end. gg – go to the first line. G – go to the last line. nG or ngg – go to line n (e.g., 10G).

3. Speed up Git‑related searches with Ctrl‑P

Add the following to .vimrc to configure Ctrl‑P for Git or silversearcher‑ag auto‑completion:

et g:ctrlp_use_caching = 0
if executable('ag')
  set grepprg=ag --nogroup --nocolor
  let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
else
  let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
endif
let g:ctrlp_prompt_mappings = {
  'AcceptSelection("e")': ['<space>', '<cr>', '<2-LeftMouse>'],
}

It is recommended to use the vim-scripts/gitignore plugin.

4. Run tests efficiently with vim‑vroom and tmux

Map <Leader>r (or <Space>r if Space is the leader) to execute tests via vim‑vroom. Running tests in a separate tmux pane allows simultaneous code editing and test monitoring.

5. Use :normal in visual mode for batch edits

Select lines in visual mode ( V) and execute a normal‑mode command across them, e.g., prepend a dash to create a Markdown list: :'<,'>normal I-.

6. Powerful substitution with :substitute

Use :%s= *$== to delete trailing spaces on every line. The % range denotes the whole file, and *$ matches any number of spaces at line ends.

7. Visual illustration

Vim usage demo
Vim usage demo
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

VimCommandLineEditorTipsGitIntegration
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.