• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/28

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

28 Cards in this Set

  • Front
  • Back

Command Mode

This mode of vi/vim accepts commands which are usually in the form of individual letters such as a and i.

Command Mode: l

Moves the cursor one character to the right.

Command Mode: h

Moves the cursor one character to the left.

Command Mode: j

Moves the cursor down one line.

Command Mode: k

Moves the cursor up one line.

Command Mode: yy

Will yank (copy) the line the cursor is currently on. 2yy will copy the entire line and the one beneath it (2 lines), 3yy does 3, and so on.

Command Mode: p

Paste the contents from yanked yy text starting at the line below the cursor.

Command Mode: P

Paste the contents from yanked yy text starting at the line above the cursor.

Command Mode: G

Moves cursor to the beginning of the last line of the file, by default.




To move to a different line you append the line number before G (for example, to move to the beginning of the first line 1G).

Command Mode: L

Moves the cursor to the beginning of the last line in the terminal screen.

Command Mode: H

Moves the cursor to the beginning of the first line in the terminal screen.

Command Mode: o

Opens insert mode to insert text, creating a new line below the current cursor position.

Command Mode: u

Undo

Command Mode: / or ?

Search function. Example: /root (will search the current file for all occurrences of root). Navigate to the next occurrence using the n key. Navigate to the previous occurrence using N (Shift+n). / searches forward. ? searches backward.

Insert Mode

Insert mode allows you to add/edit text inside of a file.

Inserting into Insert Mode: i

Insert text and not replace it.

Inserting into Insert Mode: R

Overwrite existing text when new text added.

Inserting into Insert Mode: cw

Remove current word that the cursor is on and insert into insert mode to add text.

Inserting into Insert Mode: cc

Removes the entire line of text the cursor is on and enters into insert mode to add text.

ex Mode (colon (:) Mode)

You enter into ex mode by typing a :. This will open on the bottom of the screen a command prompt starting with a :. This is why it's sometimes referred to as colon mode.




ex mode is used for saving and manipulating files. You must be in command mode before entering into ex mode.

ex Mode :w

Saves changes to a file.

ex Mode :wq

Saves changes to a file and quits out of a file.

ex Mode :q

Quits a file without saving changes

ex Mode Searching and Replacing Text:


%s/{search}/{replacement}

Will replace the first occurrence on each line of the search value with the replacement value.

ex Mode Searching and Replacing Text:


%s/{search}/{replacement}/g

Will replace all occurrences of the search value with the replacement value. Adding the g means "global"

ex Mode :e {file path}

Will load the new file into the vi editor for editing. This will only occur if the current changes to the file being edited are saved.

ex Mode :r

Allows you to bring contents of an old file into a new one.

ex Mode :!

Allows you to run shell commands from within vi. Example: !ls /etc.