• About Us
    • New York
  • Work
  • Capabilities
  • Careers
  • Technology
  • Blog
  • Contact Us
  • About Us
    • New York
  • Work
  • Capabilities
  • Careers
  • Technology
  • Blog
  • Contact Us
March 28, 2012

A Very Brief Introduction to Vim

Posted by Christopher Davis

Vim is not your traditional text editor. Folks my age are very relient on computer mice, and we’re used to removing our hands from the keyboard to click around and get to where we want to go. Vim is a different sort of editor in the respect that all the work is done form the keyboard. In fact, if you’re good at it, your fingers almost never have to leave home row.

The big challenge to using Vim is stated right on it’s about page: Vim is a tool. It’s not going to hold your hand or come built in with defaults. It’s configurable, and you’ll have to learn to use it.

If you’re on a Mac, you already have vim. Just open up terminal, type vim, and hit enter. If you’re on windows, or would like a full color GUI version of Vim, you’ll need to head to the download page to get it.

The Three Modes & Moving Between Them

Vim has three modes: normal, insert, and visual. Visual mode is outside the scope of this introduction. When you open up a text editor, you can usually start typing right away. Vim is different, you start in normal, or command, mode – you can’t actually enter any text yet. To get to insert mode, you must hit the i key. After switching to insert, you can type away.

To get back to normal mode, simply hit the escape key. Alternatively, you can use control+[ to return to normal mode.

What Good is Standard Mode Anyway?

Remember when I said above that, if you’re good with Vim, your fingers rarely have to leave home row? Before we move on, enter some text in vim: From the command line type vim and hit enter. Once inside the program, hit “i” to enter insert mode and type away.

All done? Hit escape to return to normal mode. Now move around the text with the h, j, k, and l keys. Typing “h” will move your cursor left. “l” will move it right. “k” will move the cursor up a line; “j” will move it down.

Movement goes beyond just one character at a time. Easily move around words with ^, b, B, e, and E keys: ^ (shift + 6) takes you to the beginning of a line, b and B will move you to the beginning of the previous (or current) word, and e and E will take you to the end of the next word.

Basic Vim Commands

In addition to moving around, you can also use normal mode to enter commands. All vim commands are prefaced with a colon (:).

What to delete an entire line? In normal mode type :d and hit enter. Line gone! Whoops, did you mess up? Hit the “u” key to undo.

You can jump to any line in file by typing :n where n is the line number. Copy a line of text with :y – “y” stands for “yank”. To place copied text, hit the “p” key to place it below the line with cursor or shift+p to place it above the current line.

Vim Configuration

The real strength of vim is that it’s highly configurable. The .vimrc is where that happens. Placed in your home directory on unix-like systems (OSX and Linux distros), you’ll never find this file in Finder – files starting with a dot don’t get viewed there.

.vimrc configurations are a bit outside the scope of this article, but suffice it to say that everything in vim is configurable all the way down to the keyboard shortcuts. The best way to learn? Head over to github and do a search for “dotfiles”. Repos that you find will likely contain other folk’s vimrc’s. Take a look, if you see an option that looks interesting, head back over to Vim, enter the normal mode, and type :h theoption to see what it’s all about.

Vim Resources

    • Vimcasts — great video tutorials


  • Your Problem with Vim is that you Don’t Grok vi
  • github — Looking at other people’s configs is a great way to learn!

 

devDevelopmenttext editorvim
Previous
Next

Latest White Papers

  • Shifting Plans for 2020 & Beyond
  • Game On: How Brands Can Log Into A Diverse Multi-Billion Dollar Industry
  • What CCPA Means For Brands
  • How Google is Improving Consumer Data Privacy
  • Ways to Prepare for the Cookieless Future
  • See all White Papers

Featured Posts

  • Ad Age Names PMG #1 Best Place to Work in 2021
  • MediaPost Names PMG Independent Agency of the Year
  • PMG Client Portfolio Trends During Amazon Prime Day 2020
  • A Closer Look at the Congressional Big Tech Market Power Report
  • What to Know About Reddit

Categories

  • Consumer Insights
  • Content
  • Creative Design
  • Data Analytics
  • Development
  • Digital TV & Video
  • Ecommerce
  • Industry News
  • Local
  • Mobile
  • Paid Search
  • PMG Culture
  • Programmatic & Display
  • SEO
  • Social Media
  • Structured Data
Fort Worth

2845 West 7th Street
Fort Worth, TX 76107

Dallas

3102 Oak Lawn Avenue
Suite 650
Dallas, TX 75219

Austin

823 Congress Avenue
Suite 800
Austin, TX 78701

London

33 Broadwick Street
London
W1F 0DQ

New York

120 East 23rd Street
New York, NY 10010

Get in touch

(817) 420 9970
info@pmg.com

Subscribe to the PMG Newsletter
© 2021 PMG Worldwide, LLC, All Rights Reserved
  • Contact
  • Privacy Policy
 Tweet
 Share
 Tweet
 Share
 Tweet
 Share
 LinkedIn
We and our partners use cookies to personalize content, analyze traffic, and deliver ads. By using our website, you agree to the use of cookies as described in our Cookie Policy.