Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To edit a file in a server terminal, run vim filename, use i to start typing, then press Esc before saving or quitting. Vim opens in Normal mode, where keys are commands rather than text. This short guide covers the essentials for making a small change over SSH, even if your Vim experience is rusty.

How do you open a file with Vim on a server?

  1. At the server’s shell prompt, run vim filename, replacing filename with the path to the file you want to edit. Vim documents this as the common way to start editing one file from a terminal: Vim User Manual: Starting Vim.
  2. If the command is unavailable, use an editor installed on that system or ask the administrator which editor is available. Do not assume every server has Vim.

Vim starts in Normal mode. In this mode, keys such as h and x perform actions; they do not insert those characters into the file. Press i to enter Insert mode and type text. Press Esc to return to Normal mode before issuing commands.

How do you move around and make a small edit?

In Normal mode, the basic movement keys are h (left), j (down), k (up), and l (right). The arrow keys also work in many Vim setups. Move the cursor to the intended spot, press i to insert before it, and type the change. Press Esc when you are done typing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a simple deletion, move to the character and press x. To undo the last change, press u; to redo an undone change, press Ctrl-r. These are enough to handle many small corrections without learning Vim’s broader command set.

How do you save and quit Vim?

First press Esc to ensure you are in Normal mode. Type the command below and press Enter:

  • :w saves the file and leaves Vim open.
  • :q quits Vim if there are no unsaved changes.
  • :wq saves and quits.
  • :q! quits without saving changes.

If Vim refuses to quit because the file has unsaved changes, decide whether to keep them: use :wq to save and exit, or :q! to discard the edits and exit. The exclamation mark in :q! overrides the unsaved-change warning, so use it only when you intend to lose those changes.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Where can you practice or look up Vim commands?

Vim’s own documentation offers three useful ways to continue. Its first-steps chapter is designed to provide enough to edit a file, though not yet well or fast, and covers insertion, movement, deletion, undo and redo, exiting, and help: The first steps in Vim.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
  • Look something up while working: type :help topic, substituting a command or subject for topic. Vim’s help is extensive, cross-referenced, and maintained with the software. Start with :help if you are unsure what to search for.
  • Practice beginner commands: run Vim tutor from the shell, typically with vimtutor. Vim’s help identifies it as a short interactive beginner course; official pages differ on its stated duration, so there is no single reliable time estimate.
  • Follow a guided manual: the Vim User Manual proceeds from simple tasks to more complex ones. Vim also provides a Reference Manual for precise details, with links between the two.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.