Skip to content

Instantly share code, notes, and snippets.

@Fractalbonita
Last active February 4, 2021 19:13
Show Gist options
  • Save Fractalbonita/9d152dad18b7f431cd39d13ad699e86e to your computer and use it in GitHub Desktop.
Save Fractalbonita/9d152dad18b7f431cd39d13ad699e86e to your computer and use it in GitHub Desktop.

Vim

Overview

  • Vim stands for Vi improved
  • text editor
  • things cannot be written in root directory

Modes

  • there are three modes
  • insert mode — text editing
  • command mode — primary mode for copying, pasting, searching
  • last line mode — searching, saving, editing

Basic commands

Start

  • vim — open Vim in terminal
  • vi — open Vim in terminal
  • vi [file] — create new file and open file with Vim
  • show line numbers :set number
  • hide line numbers :set nonumber
  • highlight syntax :syntax on

Change mode / navigate

  • i — initiate insert mode
  • esc — change from insert mode to command mode
  • : — change to last line mode

Search

  • /[search_term] — find the specified search term

Edit

  • c[navigation]c stands for change, e.g.
  • ce — change until end of word
  • cb — chnage until start of word
  • ciw — change whole word (change inner word)
  • ci( — change everything inside brackets-pair
  • ci" — change everything inside quotes
  • cc — change whole line
  • C — change until end of line
  • c0 — change ntil start of line
  • c^ — change until first character of line
  • d[navigation] — delete (see change

Help

  • :help or :h— open help manual
  • :help [item] — search item in help manual
  • :help 42 — open chapter 42 in help manual

Exit

  • :x — write and exit Vim
  • :wq — write and quit (save changes and exit Vim)
  • ZZ — write and quit (save changes and exit)
  • esc :q! — hard exit (discard)

Predecessors of Vim

vim --> vi --> ed [-i-d] --> ex

ed: 1. ... editor on unix line-oriented (lines can be edited)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment