FactorPad
Faster Learning Tutorials

Linux vim command summary with examples

vim allows you to edit text files.
  1. Purpose - Learn what vim is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with vim.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, October 30, 2016
Updated: August 3, 2018
In this tutorial, 57 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / technology  / linux essentials  / vim command


The Linux vim command (Vim text editor)

Beginner

Learn to edit text with a fast local editor at the Linux command line.

Video Tutorial

Linux vim command summary with examples (3:38)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our fifty-seventh word, or command to memorize is vim from our category Text.

vim allows you to edit text files.

Recall from video 20 on nano and video 56 on emacs, I'm introducing three text editors, so you know what's out there, but not to dive into the functionality.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The vim command has over 50 options and the argument is a text file you'd like to edit, and because vim is a highly-customizable text-editing program, its list of internal keystrokes is beyond our scope here.

Like most commands, help is available with double-dash --help. Once inside vim, see internal help by hitting the escape key Esc, then :, then typing help and Enter.

To leave, hit escape Esc, then colon :, q, and Enter.

So why is vim an important command? Well coders spend a lot of time editing text, often without taking hands off the keyboard, so evaluate if vim is for you. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Let's start with the vim --help option, and redirect it > to a file called video57.txt, similar to what we did in video (tutorial) 56.

$ vim --help > video57.txt

Next, type vim and that filename video57.txt.

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 01:41:24) usage: vim [arguments] [file ..] edit specified file(s) or: vim [arguments] - read text from stdin or: vim [arguments] -t tag edit file where tag is defined or: vim [arguments] -q [errorfile] edit file with first error Arguments: -- Only file names after this -v Vi mode (like "vi") -e Ex mode (like "ex") -E Improved Ex mode -s Silent (batch) mode (only for "ex") -d Diff mode (like "vimdiff") -y Easy mode (like "evim", modeless) -R Readonly mode (like "view") -Z Restricted mode (like "rvim") -m Modifications (writing files) not allowed -M Modifications in text not allowed -b Binary mode -l Lisp mode -C Compatible with Vi: 'compatible' -N Not fully Vi compatible: 'nocompatible' -V[N][fname] Be verbose [level N] [log messages to fname] -D Debugging mode -n No swap file, use memory only -r List swap files and exit -r (with file name) Recover crashed session -L Same as -r -A start in Arabic mode -H Start in Hebrew mode -F Start in Farsi mode -T <terminal> Set terminal type to <terminal> -u <vimrc> Use <vimrc> instead of any .vimrc --noplugin Don't load plugin scripts -p[N] Open N tab pages (default: one for each file) -o[N] Open N windows (default: one for each file) -O[N] Like -o but split vertically + Start at end of file +<lnum> Start at line <lnum> --cmd <command> Execute <command> before loading any vimrc file -c <command> Execute <command> after loading the first file -S <session> Source file <session> after loading the first file -s <scriptin> Read Normal mode commands from file <scriptin> -w <scriptout> Append all typed commands to file <scriptout> -W <scriptout> Write all typed commands to file <scriptout> -x Edit encrypted files --startuptime <file> Write startup timing messages to <file> -i <viminfo> Use <viminfo> instead of .viminfo -h or --help Print Help (this message) and exit --version Print version information and exit "video57.txt" 51L, 2161C 1,1 Top

Here it is, you can use arrows, and PgUp and PgDn to scroll. Here we only have time for this quick look, unfortunately.

So, to quit, type that combination Esc, :, q and Enter.

$ vim --help > video57.txt $ vim video57.txt $ _

And last, let's head back in without a file (using vim).

~ ~ ~ ~ ~ ~ ~ ~ ~ VIM - vi IMproved ~ ~ version 7.4.576 ~ by Bram Moolenaar et al. ~ Modified by pkg-vim-maintainers@lists.alioth.debian.org ~ Vim is open source and freely distributable ~ ~ Help poor children in Uganda! ~ type :help iccf<Enter> for information ~ ~ type :q<Enter> to exit ~ type :help<Enter> or <F1> for on-line help ~ type :help version7<Enter> for version info ~ ~ ~ ~ ~ 0, 0-1 All

And here the Esc, :, help, and Enter. Here's some information, so please review this later.

And then let's leave. Here we go Esc, :, q, and Enter.

$ vim --help > video57.txt $ vim video57.txt $ vim $ _

Very good.

A Final Tip

Okay now you know how to use vim. And you know the syntax for commands, options and arguments.

One last tip about the vim command. So showing you emacs quickly here was meant to kick off your journey and should you work best in a GUI, both programs are available there too.

Okay, thanks for visiting today. I hope this was a helpful introduction to the vim (editor) command.

To be totally fair, this tutorial is the simpleist of introductions. My preferred editor is now vim and I'm working on a tutorial dedicated to it. Sign up for reminders so you're informed when it comes out. Thanks, -Paul


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Subscribe to our YouTube Channel here to be notified of new content.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the emacs command, hit Back.
  • This concludes a small set of tutorials on text, join us for the history command. Click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / vim command



 
 
Keywords:
linux vim editor
linux vi
vim editor
vim guide
fast editor vim
vim tutorial
linux local text editor
vim summary
vim exit
quit vim
linux text editor
modal editor
edit text in linux
vim save and exit
vim quit