$linuxjunkies
>

vim(1)

A highly configurable text editor that improves upon vi with additional features and modes.

UbuntuDebianFedoraArch

Synopsis

vim [OPTION]... [FILE]...

Description

Vim is a modal text editor that operates in different modes: Normal mode for navigation and editing, Insert mode for typing text, and Command-line mode for executing commands. It is renowned for its efficiency through keyboard-driven workflows and powerful text manipulation capabilities.

Vim reads configuration from ~/.vimrc and supports syntax highlighting, plugins, and scripting. It is the de facto standard editor on most Unix-like systems and is known for a steep learning curve but exceptional productivity once mastered.

Common options

FlagWhat it does
-c {command}Execute Ex command after loading file (e.g., -c ':set number')
-ROpen file in read-only mode
+{num}Jump to line number {num} when opening file
-u {file}Use {file} as vimrc instead of ~/.vimrc
-NNo-compatible mode; use improved features
-dDiff mode; compare multiple files side-by-side
-nDisable swap file creation
+/{pattern}Jump to first occurrence of {pattern}
-oOpen all files in horizontal split windows
-OOpen all files in vertical split windows

Examples

Open myfile.txt for editing; creates it if it doesn't exist

vim myfile.txt

Open myfile.txt and jump to line 50

vim +50 myfile.txt

Open myfile.txt and jump to first occurrence of 'TODO'

vim +/TODO myfile.txt

Open both files in diff mode to compare changes

vim -d file1.txt file2.txt

Open /etc/passwd in read-only mode to prevent accidental changes

vim -R /etc/passwd

Open myfile.txt with line numbers displayed

vim -c ':set number' myfile.txt

Open three files in horizontal split windows

vim -o file1.txt file2.txt file3.txt

Start vim using an alternate configuration file

vim -u ~/.vimrc-minimal

Related commands