Difference between revisions of "I2rda Course Cheatsheet"
Line 33: | Line 33: | ||
* <code>|</code> often called the pipe operator: directs output of one command into another command. | * <code>|</code> often called the pipe operator: directs output of one command into another command. | ||
− | + | = Keybindings for using the history file = | |
* <code>:<RET></code>: save command in history, do not execute. | * <code>:<RET></code>: save command in history, do not execute. | ||
Line 44: | Line 44: | ||
* <code>!!:gs/then/now/:p<RET></code>: as above except do not execute. | * <code>!!:gs/then/now/:p<RET></code>: as above except do not execute. | ||
− | + | = Using vim = | |
* type <code>vim</code> to get in, and <code>:q!</code> to get out without saving. | * type <code>vim</code> to get in, and <code>:q!</code> to get out without saving. | ||
Line 56: | Line 56: | ||
* search via "/", ":set hlsearch" to see all the hits | * search via "/", ":set hlsearch" to see all the hits | ||
− | + | = Getting by in only normal mode = | |
* movement keys, "w" jump via start of words; "e" jump via ends; "fc" jump to next c | * movement keys, "w" jump via start of words; "e" jump via ends; "fc" jump to next c | ||
Line 67: | Line 67: | ||
* Visual: Activated by "v" or "V" (visual block), sub-box at the bottom open, rich command language | * Visual: Activated by "v" or "V" (visual block), sub-box at the bottom open, rich command language | ||
− | + | = Advanced vim but really useful commands = | |
* ":colorscheme desert" chang to the desert colour scheme, "morning" "delek" many others | * ":colorscheme desert" chang to the desert colour scheme, "morning" "delek" many others | ||
Line 81: | Line 81: | ||
− | + | = GNU screen program = | |
− | + | * type <code>screen</code> to get in. | |
− | + | * type <code>exit</code> to get out of your screen sessions | |
− | |||
− | * type exit to get out of your screen sessions | ||
* <code>ctrl+l, n</code>: cycle through screen windows | * <code>ctrl+l, n</code>: cycle through screen windows | ||
* <code>ctrl+l, :hardcopy RET</code>: create a file with a copy of all inputs and outputs of your session. | * <code>ctrl+l, :hardcopy RET</code>: create a file with a copy of all inputs and outputs of your session. | ||
* <code>ctrl+l,d</code>: detach screen session | * <code>ctrl+l,d</code>: detach screen session | ||
+ | * type <code>screen -r</code> to recover a detached session. | ||
* <code>ctrl+l,K</code>: abandon current session. It will be lost. | * <code>ctrl+l,K</code>: abandon current session. It will be lost. | ||
* <code>ctrl+l,ESC</code>: enter scroll or copy mode. <code>PgUp</code> an <code>PgDn</code> will now work. <code>Esc</code> to get out. | * <code>ctrl+l,ESC</code>: enter scroll or copy mode. <code>PgUp</code> an <code>PgDn</code> will now work. <code>Esc</code> to get out. | ||
− |
Revision as of 18:04, 7 May 2017
Contents
-
ctrl + a
: go to beginning of line -
ctrl + e
: go to end of line -
ctrl + w
: delete current word backwards, word behind if in space -
ctrl + /
: undo changes -
ctrl + x, <BACKSPACE>
: search backwards for a character, here? -
ctrl + r, ?
: search backwards for a character, here? -
alt + b
: move backwards word-wise. -
alt + f
: move backwards word-wise -
alt + d
: delete current word forwards, next word if in space -
ctrl + k
: delete to end of line
Pagers: man
, less
and vim
keys
-
q
, to get out again. -
gg
, for top of the page -
G
, for bottom of page -
Ctrl+f
, to advance one page forward. -
Ctrl+b
, to move one page back. -
/
to search, it allows you type in a search term at the bottom. - To up,down,pgup and pgn keys and arorw keys all work as expected.
Linux shortcut symbols
-
.
the directory you are currently in, often used with mv, cp or ln -s to mean "in here please" -
..
the directory one level above the one you are currently in, aka. the parent directory
- - To change directory to the one above your are in:
cd ..
- To returns to the last directory you were working in before this one:
cd –
- On its own,
cd
bring you to your home directory -
~
shorthand for your home directory, where all your data is kept. -
>
directs output of one command into a file -
|
often called the pipe operator: directs output of one command into another command.
Keybindings for using the history file
-
:<RET>
: save command in history, do not execute. -
!$<RET>
: the final argument of the last command -
!!<RET>
: the entire last command -
!:1-$<RET>
: everthing except the first word of the last command -
!$<RET>
: the final argument of the last command -
^then^now<RET>
: replace the first occurence of then in last command with now -
!!:gs/then/now/<RET>
: replace the ALL occurences of "then" in last command with "now" -
!!:gs/then/now/:p<RET>
: as above except do not execute.
Using vim
- type
vim
to get in, and:q!
to get out without saving. -
ZZ
to save onto to current filename. ":sav fname" otherwise - It opens in "normal" mode which is similar to less, in that direct editing is not expected.
- This is changed by pressing
i
. To get back to normal mode, press theESC
key. - In normal mode
u
undoes any changes -
:
while in normal mode allows command sto be entered - Visual: enabled by "v" or "V" (visual block), sub-box at the bottom open.
- After v or V, movement keys ":%" will operate on whole document, ":’a,’b" operate between two marks, ":42,45" between two line numbers
- search via "/", ":set hlsearch" to see all the hits
Getting by in only normal mode
- movement keys, "w" jump via start of words; "e" jump via ends; "fc" jump to next c
- "0" for start of line, "A" for end of line and into insert mode
- "x" delete current character, "xp" switch positions of current and next character
- "yyp" copy current line and paste it underneath
- "dd" delete line, "2d" delete this and following two lines. "dgg" delete to start, "dG" delete to end
- "dw" delete current word
- Command: Activated by ":", sub-box at the bottom open, rich command language
- Visual: Activated by "v" or "V" (visual block), sub-box at the bottom open, rich command language
Advanced vim but really useful commands
- ":colorscheme desert" chang to the desert colour scheme, "morning" "delek" many others
-
:%s/snooze/sneeze/gc
also works -
:g/sneeze/d delete all lines without sneeze"
-
:v/sneeze/d delete all lines with sneeze"
- ":42y[RET]p" paste line 42
- "d214G" delete to line 214
- "y214G" delete to line 214
-
:set list
, all non-printing characters are also shown. -
:set hlsearch
, will highlight all search occurences. -
:set nu
, show line numbers.
GNU screen program
- type
screen
to get in. - type
exit
to get out of your screen sessions -
ctrl+l, n
: cycle through screen windows -
ctrl+l, :hardcopy RET
: create a file with a copy of all inputs and outputs of your session. -
ctrl+l,d
: detach screen session - type
screen -r
to recover a detached session. -
ctrl+l,K
: abandon current session. It will be lost. -
ctrl+l,ESC
: enter scroll or copy mode.PgUp
anPgDn
will now work.Esc
to get out.