Vim / Neovim CLI Startup, Diff, and Recovery

Launch editors with flags, compare files, recover swap data, and use terminal-friendly startup patterns.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Startup commands
Open a file from shell
vim file.txt
nvim file.txt

# Start the editor on a file path.

Open file at a specific line
vim +42 app.ts
nvim +42 app.ts

# Jump directly to a target line on startup.

Open read-only
vim -R file.txt
nvim -R file.txt

# Prevent accidental writes while reviewing.

Start without user config
vim -u NONE -U NONE
nvim --clean

# Launch a clean environment for config debugging.

## Diff mode
Start in diff mode
vimdiff old.txt new.txt
nvim -d old.txt new.txt

# Open two files side by side for comparison.

Jump between diff hunks
]c  [c

# Move to the next or previous change region.

Pull or push changes across diff panes
:diffget  :diffput

# Take changes from one side or send them to the other.

## Recovery and swap workflows
Recover from a swap file
vim -r file.txt
nvim -r file.txt

# Open recovery mode for a specific file.

List recoverable swap files
vim -r
nvim -r

# Show swap files that can be recovered.

Write recovered contents elsewhere
:write recovered-file.txt

# Save a recovered buffer to a safe path first.

Recommended next

No recommendations yet.