LinuxCommandLibrary

vim

TLDR

Open a file in vim

$ vim [file]
copy
Open file at specific line
$ vim +[line_number] [file]
copy
Open in read-only mode
$ vim -R [file]
copy
Open multiple files in tabs
$ vim -p [file1] [file2]
copy
Open multiple files in split windows
$ vim -o [file1] [file2]
copy
Open and execute command
$ vim -c "[command]" [file]
copy
Compare two files (diff mode)
$ vim -d [file1] [file2]
copy

SYNOPSIS

vim [options] [file...]

DESCRIPTION

vim (Vi IMproved) is a highly configurable text editor built for efficient text editing. It extends the classic vi editor with features like syntax highlighting, visual mode, multiple buffers, and extensive plugin support.
Vim operates primarily through keyboard commands in different modes, enabling powerful text manipulation without leaving the home row. While the learning curve is steep, proficiency enables very fast editing.
Configuration lives in ~/.vimrc (or ~/.vim/vimrc). Plugins can be managed with package managers like vim-plug, Vundle, or native packages (Vim 8+).

PARAMETERS

+ line

Start at specified line number
+ command
Execute command after loading file
-c command
Execute command after loading file
-R
Read-only mode
-r
Recovery mode (recover from swap file)
-p
Open files in tabs
-o
Open files in horizontal splits
-O
Open files in vertical splits
-d
Diff mode
-b
Binary mode
-x
Edit encrypted file
-u vimrc
Use specified vimrc file
-N
Not compatible mode (use Vim defaults)

NORMAL MODE COMMANDS

Movement: h/j/k/l (left/down/up/right), w/b (word), 0/$ (line start/end), gg/G (file start/end)
Editing: i (insert), a (append), o (new line below), x (delete char), dd (delete line), yy (copy line), p (paste)
Save/Quit: :w (save), :q (quit), :wq (save & quit), :q! (quit without saving), ZZ (save & quit)
Search: /pattern (search forward), ?pattern (search backward), n/N (next/previous match)
Undo/Redo: u (undo), Ctrl+r (redo)

MODES

Normal: Default mode for navigation and commands
Insert: Text input (i, a, o, etc.)
Visual: Selection (v for char, V for line, Ctrl+v for block)
Command: Ex commands (:)
Replace: Overwrite text (R)
Press Esc to return to Normal mode from any other mode.

CAVEATS

Vim's modal editing is different from most editors. New users often struggle with modes; remember Esc returns to Normal mode.
Configuration can become complex. Start simple and add features as needed. Use :help extensively—Vim has excellent built-in documentation.
If stuck with a frozen terminal after Ctrl+S (XOFF), press Ctrl+Q to resume.

HISTORY

Vim was created by Bram Moolenaar and first released in 1991 as an improved clone of vi. Vi itself was created by Bill Joy in 1976. Vim added features while maintaining vi compatibility, becoming one of the most popular text editors among developers.

SEE ALSO

vi(1), nvim(1), nano(1), emacs(1), vimtutor(1)

> TERMINAL_GEAR

Curated for the Linux community

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

Bmax Mini PC B2 Power Intel 5205U 8GB DDR4 256GB M.2 NVMe SSD ,HDMI 1.4&DP 1.2, USB3.2,4K Dual Display 2.4G/5G WiFi & BT5.0 Mini Desktop Computers /Office/Design

$169.99
New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

New Raspberry Pi 3 Model B+ Board Raspberry PI 3B+

$54.00
KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

$16.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

$16.99
nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

nuphy Air75 V2 Portable 75% Mechanical Keyboard,Wireless Keyboard

$129.95
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99