vim
Edit text files
TLDR
Open a file
Open a file at a specified line number
View Vim's help manual
Save and quit the current buffer
Enter normal mode and undo the last operation
Search for a pattern in the file (press
Perform a regex substitution in the whole file
Display the line numbers
SYNOPSIS
vim [options] [file ...]
vim [options] -
vim [options] -t tag
vim [options] -q [errorfile]
PARAMETERS
+N
Start editing at line number N.
+command
Execute command after the first file is read.
-c command
Like +command, execute command after the first file is read.
-b
Binary mode. Edit a binary file (sets 'binary' option).
-d
Diff mode. Start in diff mode, comparing up to four files.
-g
Start in GVim (graphical Vim) if available.
-h
Show a brief help message and exit.
-i file
Use file for `viminfo` instead of the default.
-o[N]
Open N windows, one for each file, arranged horizontally. If N is omitted, one window per file.
-O[N]
Open N windows, one for each file, arranged vertically. If N is omitted, one window per file.
-R
Read-only mode. The 'readonly' option is set.
-s scriptin
Read commands from the script file scriptin (like :source!).
-S sessionfile
Source sessionfile after loading the first file (like :source!).
-t tag
Edit the tag tag (uses a tags file to jump to the definition).
-u vimrc
Use vimrc for initialization instead of default `~/.vimrc`.
-v
Show version information and exit.
-Z
Restricted mode (only if compiled in). Disables shell commands and writing files.
DESCRIPTION
Vim, short for "Vi IMproved," is a highly configurable text editor built to enable efficient text editing. It's a modal editor, meaning it operates in different modes for specific tasks (e.g., normal, insert, visual, command-line). This modal design, while presenting a steep learning curve for newcomers, allows experienced users to perform complex editing tasks with remarkable speed and precision, often without needing to touch the mouse.
Originally developed by Bram Moolenaar in 1991 as an extension of the classic vi editor, Vim has evolved into a ubiquitous tool across Unix-like operating systems. Its power comes from its extensive command set, a rich plugin ecosystem, powerful scripting capabilities, and deep integration with the terminal environment. Vim is ideal for programmers, system administrators, and anyone who deals with large volumes of text or code, offering features like syntax highlighting, multi-level undo, visual mode selection, and robust search-and-replace functionalities. It's renowned for its efficiency, stability, and keyboard-centric workflow.
CAVEATS
Vim has a steep learning curve due to its unique modal editing paradigm, which can be counter-intuitive for users accustomed to traditional "insert-always" editors. Mastering Vim requires dedicated practice and a willingness to learn a new way of interacting with text. Its extensive configuration options, while powerful, can also be overwhelming for beginners.
MODAL EDITING
Vim operates in distinct modes. The primary modes are:
Normal mode (command mode): For navigation and executing commands.
Insert mode: For typing text.
Visual mode: For selecting blocks of text.
Command-line mode: For executing `ex` commands (e.g., saving, quitting, search/replace) by typing `:`.
CONFIGURATION (<I>.VIMRC</I>)
Vim is highly customizable. Most user preferences, key mappings, and plugin configurations are stored in a plain-text file, typically `~/.vimrc` (or `_vimrc` on Windows), allowing users to tailor the editor precisely to their workflow.
EXTENSIBILITY (PLUGINS)
Vim supports a vast ecosystem of plugins, written in Vimscript, Python, Ruby, and other languages. These plugins extend Vim's functionality, adding features like advanced file browsing, language-specific IDE features, version control integration, and much more.
HISTORY
Vim's origins trace back to Bill Joy's vi editor, released in 1976 as part of the Berkeley Software Distribution (BSD) Unix. While `vi` was revolutionary, it lacked several modern features.
In 1991, Bram Moolenaar released Vi IMproved (Vim) for the Amiga computer, aiming to add new functionalities like multi-level undo, syntax highlighting, and a visual mode, which `vi` lacked. Over the years, Vim was ported to various platforms, including Unix, Linux, and Windows, and continuously enhanced with features like graphical user interfaces (GVim), scripting capabilities (Vimscript), and a robust plugin architecture. Its development has been driven by a strong community, making it one of the most mature, stable, and widely used text editors in the world.