User Tools

Site Tools


unix week5

Feb 26, 2019


if [condition]; then
#stuff happens for when you run it

#stuff that always happens


for ( (variable;condition;increment) ); do

(the greatest text editor known to man…)

-'vi (filename)' starts editing
-'vi (line number) (filename)' this will open the file on that line

Vi is a moded editing system, invented before the mouse and when keyboards had less keys.


Command mode
- This is the starting mode
- All other modes are accessed from here
- Escape usually brings you here
- Nearly every key stands for a command
- (see below for commands)

Insert mode
Typing of text happens in this mode
These are some ways to start insert mode from command mode:
-'i' starts insert mode (starts before the current cursor position)
-'I' starts insert mode (starts the cursor at the beginning of the line)
-'a' starts insert mode (starts after where the cursor is)
-'A' starts insert mode (starts the cursor at the end of a line)
-'o' starts insert mode (starts by creating a new line under the cursor line)
-'O' starts insert mode (starts by creating a new line above the cursor line)

Other Commands
-'v' for visual mode (for selecting large portions visually)
-'/' starts a search (like a man page)
-'h' moves cursor left
-'j' moves down
-'k' moves up
-'l' move right
-'w' moves right one word (w counts . : and the like, but W only spaces) [e does the same but to the end of the word]
-'b' moves back a word (b, B like w and W)
-'{' and '}' navigates by paragraph
-'(number)G' goes to that line number
-'~' toggles the case where the cursor is

-'yy' yank line (copy, there are multiple buffers use “(letter) to select)
-'dd' cut line
-'cc' change line
-'p' is paste (P like o and w)
-'x' deletes by character
'y', 'c' and 'd' can be used to do by any amount (word line etc)
i.e. #yl yanks # of characters to the right
-'.' repeats the last command
-':wq' saves and exits
-':q!' exits without saving

You can prefix many of these commands (i.e. with numbers for repitition)

journal/spring2019/bmather2/week5.txt · Last modified: 2019/02/27 14:20 by bmather2