For help with wiki syntax:
Class Notes
Important Idea
There are two modes of operation that can be observed when using a text editor:
- Issuing a command
- Inserting text
Insert Commands
i: enter insert mode before cursor
a (append): enterinsert mode after cursor
I: enter insert mode at the beginning of the line that the cursor is currently on
A: enter insert mode at the end of the current line
o: append a new line below the current line
O: append a new line above the current line
Navigation Commands
“Arrow Keys” - Cursor Movement (navigation by character)
k: up, l: right, j: down, h: left
Note: Adding a number before any of the commands allows movement by that many characters:
Ex.) 8h
w: navigates forward by word
W: navigates forward by space
b: navigates backwards by word
B: navigates backwards by space
G, gg: go to line (with a number placed in front of the command)
Manipulation Commands
x: delete (cutting)
xxx: delete “3”
X: akin to a backspace
dw,dW: see above syntax for w,W (deletes by…)
db, dB: see above syntax for b,B (deletes by…)
dd: deletes the current line
d^: deletes backwards from cursor
d$: deletes forwards from cursor
.: repeats the last used manipulation command
{ , }: movement backwards/forwards by paragraph
(Shift)~: toggles case of letter that the cursor is on (if held then will proceed through rest of document)
/: Allows for the user to search the document
n, N (while in a search): Moves the cursor to the next and previous result respectively
r: redo
u: undo
p: paste below cursor
P: paste above cursor
cc: cut into insert mode
cw, cW: see above syntax for w,W (cuts by…)
cb, cB: see above syntax for b,B (cuts by…)
yy: paste into insert mode
yw, yW: see above syntax for w,W (paste by…)
yb, yB: see above syntax for b,B (paste by…)
y{, y}: see above syntax for {,} (paste by…)
Extended VI Commands
To enter press colon while in command mode(:)
:w :save
:w! :force save
:wq :save and exit
:q :quit
:q! :force quit
:co0 :copy to current line (line #, example 0)
:%s/(pattern 1)/(pattern 2)g :replaces any example of (pattern 1) with (pattern 2)
Customization Commands
All examples of the number sign represent any number to apply
:set tabstop= #
:set shiftwidth=#
:set number :toggles side numbering in VI
:syntax on
:set cursorline
:set cursorcolumn
:colorscheme (example) :Turns the default color scheme to another (press tab after command to see choices)
(Created 9/16/2017) - Robin Lash
Advanced Scripting
(Basic scripting can be found in the example scripts created for reference in class)
Vertical Operators
- Unary: if exists (performs one operation)
- Binary: if “name”/“number” is greater than ….. (two operations)
Operators
- eq: is equal to
- ne: is not equal to
- le: is less than or equal to
- lt: is less than
- gt: is greater than
- gr: is greater than or equal to
- !: invert logic
&&: and and
“||”: or or
(Edited 9/23/17 Robin Lash)
Example HTML
(for wpa0)
<!DOCTYPE html> - Tells the type of document
<html>
<head> - Start of the page
<title>Title of the Webpage</title>
<style>
“Style of the header of the page”
</style>
</head>
<body> - Main content of the page
<h1>Main Header of the Document<h1>
<p style=style of the header/paragraph>
<b> - Bold the words
<font size=“Example #” Text goes in after</font>
</b>u
<br> - Create a space in the document
</p>
Example:
<a href (set a reference to another link)=“adventure.html”>Name of the Link</a>
<p></p> - Create a new paragraph
<ul> - Create a new list
<li> List item </li>
</ul>
</body>
</html>
Regular Expressions
Basic:
. : match to any single symbol
* : match 0 or more of the previous
[]: (character class) - match any of the enclosed
[^]: (inverted character class) - do not match any of the enclosed
“^” : match start of line
“$” : match end of line
\< : match start of word
\> : match end of word
Extended:
- Recommended to use egrep
+ : match 1 or more of the previous
() : perform grouping
“|” : or
? : match 0 or 1 of the previous
(Robin Lash - 10/21/2017)
Mouse Movement:
xte : xte 'option 'parameter''
xte 'mousemove x y' : Moves mouse to x,y. Positive values mean moving right, down. Negative values mean moving left, up.
xte 'mousermove x y': Moves the mouse x,y, relative to where it already was.
xwininfo: command that allows for a specific window to be selected for cursor movement, -root means the size of the desktop/window manger.
(James vanDright - 10/28/2017)
Useful tools for icp0
scp
Tool to transfer items between the pod and the lab46 account:
Syntax:
[command][filename][user]:[location] - (Use a colon for home directory)
scp icp0-0.sh pod57: src/unix/icp0
scp icp0-1.sh user@pod57:
scp 1cp0-2.sh user@lab46:
(Robin Lash - 10/28/2017)
Helpful Tools in lab46
du -hs
- Displays your disk usage
(h - “human readable”)
(s - summary)
quota
- Shows how much data we are using, and how much we have left to use.
Example of the output:
[blocks][quota][limit]
[blocks]: (how much data we are using)
[quota]: (how much we can use before we approach a soft wall)
[limit]: (the hard limit we cannot go past)
[files][quota][limit]
[files] : (how many unique files there are)
[quota] : (how much we can use before we approach a soft wall)
[limit]: (the hard limit we cannot go past)
(Robin Lash - 11/4/2017)
More useful items/good reminders
& : enables a program to work in the background, which is useful for mtPaint in icp
bc : Bench Calculator: a nice program that can do math in the terminal. Some useful things to note are: Echo works with bc, and if a file has say, “3+10+9+5” in it, Echo can actually do the math. Otherwise, bc can do the complicated stuff. the usual format I use is: var= $(bc «< Mathstuff)
A general note: be careful of for loops: just one extra zero can cause a lot more processes than desired. Think about what the extra iterations will do ahead of time to save you the headache of what it will actually do.
(James vanDright - 11/4/2017)
vim shortcut which comes in handy
For those interested in copying and pasting large chunks of text, use visual mode by pressing ESC, then press V, highlight all your text, press Y to yank (copy), and P to paste anywhere you want.
-Andrei
11/14/17
Not much I can say here now that the eoce is coming up. Good luck to all. Helpful hints: don't forget to use the man pages and read all the way through the specification :D.
Refresher on File Permissions
r w x
_ _ _ (Addition of the places to get value (Octal))
4 2 1
- read bit
- write bit
- execute bit
Example:
r-x rwx rwx
5 7 7
Good information in case you accidentally let everyone else edit your file. Happy UNIXing!
(Robin Lash - 11/18/2017)