freeCodeCamp/guide/english/vim/basic-usage/index.md

1.1 KiB

title
Basic Usage

VIM Basic Usage

Open File

  • Run vim or vi and open the given filename.

Insert Mode

  • Once opening the page enter I and you will see the text "Insert Mode" at the bottom of your screen. From here you can make any changes you want to the text of your file.

Save File

  • :w

Save and Exit

  • :x
  • SHIFT ZZ
  • :wq

Exit file if no changes made

  • :q

Exit file and undo any changes made

  • :q!

Display line numbers

  • :set nu

Don't display line numbers

  • :set nonu

Add syntax color based on prog language used

  • :syntax on

About Vim

Vim is a text editor intended to be used in a CLI (command line interface) environment. It is highly configurable and built with efficiency in mind, without the need of a mouse or a graphical interface. It was built to be an improved version of the UNIX editor 'VI', or VI improved. That being said, VIM also has a GUI (Graphical User Interface) version named GVIM that shares the same core functionality as VIM but allows users additional feature such as additional menu and tool bars.