• 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/50

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;

50 Cards in this Set

  • Front
  • Back

vi syntax to open an already existing file by typing
vi syntax to create a new file

vi filename
vi newname

vi Modes
vi has two modes:
command mode - the letters of the keyboard perform editing functions. To enter command mode, press the escape key.
insert mode - the letters you type form words and sentences. Unlike many word processors, vi starts up in command mode
In order to begin entering text in this empty file, you must change from command mode to insert mode. To do this, type
i
Moving the Cursor

h - left one space
j - down one line
k - up one line
l - right one space

Deleting Characters
To delete a character from a file
To remove four characters
To delete the character before the cursor
To del a character from a file - x
To remove four characters - 4x
To delete the character beofre the cursor - X
Deleting Words
To delete a word
To delete three words
To delete a word - dw
To delete three words - 3dw
Deleting Lines
To delete a whole line, type
To delete two lines, type
To delete from the cursor position to the end of the line type
To delete a whole line, type - dd
To delete two lines - 2dd
To delete from the cursor position to the end of the line type - D
Replacing Character
To replace one character with another:
Move the cursor to the character to be replaced.
Type r
Type the replacement character
Replacing Lines
To change text from the cursor position to the end of the line:

Type C (uppercase).
Type the replacement text.
Press .

Inserting Text
To insert text in a line:

Position the cursor where the new text should go.
Type i
Enter the new text.

Appending Text
To add text to the end of a line:
Position the cursor on the last letter of the line.
Type a
Enter the new text.
To insert a blank line above the current line, type
O (uppercase)
Joining Lines
To join two lines together:
To join three lines together:
Put the cursor on the first line to be joined.
Type J
----------------------------------------------------------
Put the cursor on the first line to be joined.
Type 3J
Undoing
To undo your most recent edit, type
To undo all the edits on a single line, type
To undo your most recent edit, type - u
To undo all the edits on a single line, type - U
Moving Around in a File
forward word by word
backward word by word
to end of line
to beginning of line
to top line of screen
to middle line of screen
forward word by word - w
backward word by word - b
to end of line - $
to beginning of line - 0
to top line of screen - H
to middle line of screen - M
Moving Around in a File
to last line of screen
to last line of file
to first line of file
scroll forward one screen
scroll backward one screen
scroll down one-half screen
scroll up one-half screen
to last line of screen - L
to last line of file - G
to first line of file - 1G
scroll forward one screen - Ctrl+f
scroll backward one screen - Ctrl+b
scroll down one-half screen - Ctrl+d
scroll up one-half screen - Ctrl+u
Moving by Searching
To move quickly by searching for text, while in command mode:
--------------------------------
To repeat the search in a forward direction, type
To repeat the search in a backward direction, type
Type / (slash).
Enter the text to search for.
Press .
-------------------
To repeat the search in a forward direction, type - n
To repeat the search in a backward direction, type - N
To save the file and quit vi, type
To save the file and quit vi, type - zz
To save the edits you have made, but leave vi running and your file open:
Press .
Type :w
Press
To quit vi, and discard any changes your have made since last saving:

Press .
Type :q!
Press .

discard changes and quit file



How to close the editor
How to close editor and force it to discard chagnes

:q!



:q
:q!

start vi
start vi with a particular file

$ vi
$ vi myfile.txt

vi is different from many editors, in that it has two main modes of operation:

command mode, and insert mode.

When you first load the editor, you will be placed into command mode. To switch into insert mode, simply press the

i key

When you have finished typing, you may return to command mode. This is done by pressing your

'Esc'

save file

:w
or
:w newfilename.txt

To move the cursor around the screen, you must be in command mode.

h - Cursor left
j - Cursor down
k - Cursor up
l - Cursor right

how to delete a character

how to delete multiple character

in cmd mode use
x
20x

delete a line

delete 5 lines

d

5d

move forward 1 word
move back 1 word
move to end of word

w
b
e

move to beginning of current sentence
move to beginning of next sentence
move to beginning of current paragraph
move to beginning of next paragraph

(
)
{
}

move to start of current line
move to first non white char of current line
move to end of current line

0
^
$

first character of next line
first character of previous line

+
-

Top line of current screen
Middle line of current screen
Last line of current screen

H
M
L

Forward 1 screen
Back 1 screen
Down half screen
Up half screen

Ctrl-F
Ctrl-B
Ctrl-D
Ctrl-U

search for text forward
repeat forward search
search for text backward
repeat backward search

/text
/
?text
?

repeat previous search in forward direction
repeat previous search in backward direction

n
N

Append to end of current line
Insert before cursor
Insert at beginning of line
Open line above cursor
Open line below cursor

A
i
I
o
O

Insert tab
Move to next tab position

Ctrl-I
Ctrl-T

Delete current line
Quote next character
Move back one word

Ctrl-U
Ctrl-V
Ctrl-W

insert buffer after cursor
insert buffer before cursor

p
P

undo last change
restore current line

u
U

delete current cursor position
delete back one character
delete previous n characters

X
X
nX

repeat last change
revers case

-
~

Copy current line to new buffer
Copy current line
Copy current line into buffer x
Put contents of buffer x

y
yy
"xyy
"xp

write file
write file (ignoring warnings)
overwrite file
write file and quite

:w
:w!
:w! file
:wq

Quit
Quit (even if changes not saved)
Write file as file, leaving original untouched

:q
:q!
:w file

Quit, only writing file if changed
Quit, only writing file if changed

ZZ
:x

Reload file from disk (revert to previous saved version)
Display current filename
Edit next file

:e!
%
:n

Insert file after cursor
Run command, and insert output after current line

:r file
:r !command