Understanding the Efficiency of vim (2024)

Before we start learning how vim works, I just want to mention some commands so that people who are new to vim can use it.

# Open a file in vim
vim textfile.text
# Come out of vim
[Esc]:q # quit without saving
[Esc]:wq # save and quit
[Esc]:q! # discard changes and quit
# Navigation
h => left
j => down
k => up
l => right
# Copy
[Esc]v[h|j|k|l]y # h,j,k,l to highlight a block
# Cut
[Esc]v[h|j|k|l]d # h,j,k,l to highlight a block
# Paste
[Esc]p

What distinguishes vim from other editors? It’s a modal editor that makes it so efficient. Unlike any other editors, that only have one mode which is insertion mode, you are constantly typing and streaming text into the buffer.

Now, for writing this is great, however, as programmers, what we care about most isn’t constant flow of text but editing and navigating. I think the best analogy to explain this would be:

You can imagine programmers as painters and painters don’t spend their time continuously doing one brush stroke, they prepare the canvas, mix up the colors, and then they do individual discrete strokes.

Vim achieves this with different modes. Here are the four modes to get started with vim.

Understanding the Efficiency of vim (1)

1. Normal mode

Here, we interact with text and tell it what to do. When we launch vim, this is the default mode.

Most people are used to just typing, but in this mode, we don’t insert text into the buffer, we do other types of activities like navigation. We can get to this mode by pressing Esc. This is the default mode in vim.

2. Insert mode

You can get into this mode using i: insert, a: append, c: change. This is the mode most people are used to. So, remember, if you open vim and want to type something, switch to the insert mode using the mentioned keystrokes.

3. Visual mode

This is just like normal mode, except it works with highlighted blocks of texts. Another problem people face is copying and cutting text, you can do that in this mode. You can get here from normal mode using V, v, <Ctrl-V>.

4. Command-line mode

This is where you find texts, exit vim, navigate files, and whatnot.

To use vim, you have to think in terms of Operators, text objects, and motions, then you will unleash the real power of vim.

1. Operators

These are the verbs of the vim language. They specify actions to perform on your text objects or motions and most of them are easy to remember.

Understanding the Efficiency of vim (2)

2. Text objects

These are the actual visual text on your screen.

Understanding the Efficiency of vim (3)

Again, very simple to remember: aw: a word. Now, here we can combine these with operators to see some powerful actions. Here are a few of my favorites:

Understanding the Efficiency of vim (4)

Remember you have to be in normal mode to use these hotkeys.

3. Motions

Motions are all about efficient navigation through the file that you’ve opened. Here are some of the most useful motions:

Understanding the Efficiency of vim (5)

Let me explain how this works, suppose you press +, this would take you to the first non-blank character of the next line, but if you press 10+, it’ll take you to the first non-blank character of the 10th line from the current position.

Let me give you some more examples to make things clear.

Understanding the Efficiency of vim (6)
Understanding the Efficiency of vim (2024)
Top Articles
How much Professional Indemnity Insurance do I need? - Clarke Williams Ltd Insurance Brokers
4 Benefits of Disaster Recovery Planning | Evolve IP
Bank Of America Financial Center Irvington Photos
Ets Lake Fork Fishing Report
Robot or human?
Apnetv.con
ds. J.C. van Trigt - Lukas 23:42-43 - Preekaantekeningen
Blue Ridge Now Mugshots Hendersonville Nc
Tripadvisor Near Me
Aces Fmc Charting
Caresha Please Discount Code
Beau John Maloney Houston Tx
Craigslist Apartments In Philly
Rhinotimes
No Hard Feelings Showtimes Near Cinemark At Harlingen
Samantha Lyne Wikipedia
Craigslist Panama City Fl
Find Such That The Following Matrix Is Singular.
Las 12 mejores subastas de carros en Los Ángeles, California - Gossip Vehiculos
Forum Phun Extra
Craigslist Southern Oregon Coast
Nhl Tankathon Mock Draft
Babbychula
Parc Soleil Drowning
Craigslist Houses For Rent In Milan Tennessee
Craigslist Battle Ground Washington
Scheuren maar: Ford Sierra Cosworth naar de veiling
Macu Heloc Rate
Inkwell, pen rests and nib boxes made of pewter, glass and porcelain.
Restaurants In Shelby Montana
Jamielizzz Leaked
Stouffville Tribune (Stouffville, ON), March 27, 1947, p. 1
Memberweb Bw
Hypixel Skyblock Dyes
Powerball lottery winning numbers for Saturday, September 7. $112 million jackpot
Unlock The Secrets Of "Skip The Game" Greensboro North Carolina
Samsung 9C8
Philadelphia Inquirer Obituaries This Week
craigslist | michigan
Topos De Bolos Engraçados
The best bagels in NYC, according to a New Yorker
Craigslist - Pets for Sale or Adoption in Hawley, PA
All Obituaries | Sneath Strilchuk Funeral Services | Funeral Home Roblin Dauphin Ste Rose McCreary MB
5A Division 1 Playoff Bracket
Craigslist Woodward
My Eschedule Greatpeople Me
UWPD investigating sharing of 'sensitive' photos, video of Wisconsin volleyball team
Lyons Hr Prism Login
Free Carnival-themed Google Slides & PowerPoint templates
Latest Posts
Article information

Author: Tuan Roob DDS

Last Updated:

Views: 5575

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Tuan Roob DDS

Birthday: 1999-11-20

Address: Suite 592 642 Pfannerstill Island, South Keila, LA 74970-3076

Phone: +9617721773649

Job: Marketing Producer

Hobby: Skydiving, Flag Football, Knitting, Running, Lego building, Hunting, Juggling

Introduction: My name is Tuan Roob DDS, I am a friendly, good, energetic, faithful, fantastic, gentle, enchanting person who loves writing and wants to share my knowledge and understanding with you.