Text Processing and Editing Flashcards
How to exit Nano
Ctrl X
How to save in Nano
ctrl O
Get help in Nano
ctrl G
Open a second file within Nano
ctrl R then alt F (new buffer, otherwise it just inserts)
Swap between buffers in Nano
alt > or <
Create a new buffer (file) alongside one already open in Nano
ctrl R, alt F
Copy/cut a line in Nano
ctrl K (cuts) then ctrl U (pastes)
Mark a region in Nano
alt A, then move cursor
Copy a region in Nano
ctrl ^
(ctrl shift 6)
Find a word (string) in Nano
ctrl W.
Is not case sensitive
alt W will continue to search
How to find a replace all instances of a string in Nano?
ctrl\ or alt R
How to enter insert mode in Vim
i
How to enter command mode in Vim
:
How to enter visual mode in Vim
It opens into visual mode, otherwise hit Esc
How to delete a line in Vim
: d
Or Esc -d-d
How to save then quit Vim
:wq
How to quit without saving in Vim
:q!
How to bring up line numbers in Vim
:set number
How select a range of lines in Vim
:1,100
Copy in Vim
Y (in command)
yy (in visual)
Paste in Vim
p
Or pp
Find a string in Vim
/STRING (case sensitive)
Jump to a string instance in vim as you open
vim +/STRING FILE
How to repeat a search in Vim
/ ENTER
or from visual mode
‘n’ (forwards) N (backwards)
How to search AND replace in Vim
:s/STRING/REPLACEMENT
How to search and replace over a range of lines in Vim
:1,1000s/STRING/REPLACEMENT
Reload original file in Vim e.g to undo
:e!
Common “pr “ options
-n Display in n columns
-l n Change default 66 line page to n
-m Merge multi files in parallel column
-s c Change default separator to c
-t Omit head and tails
-w n change default 72 width to n
Common “cat” options
-A show all (inc non printing char)
-E Display $ for new line feed
-n Number lines
-s Squeeze (no display) blank lines
-T Show tabs (with ^I)
-v Show non printing (^ or M-)
What is file globbing?
When wildcards are added to a filename argument, so the name can be expanded into multiple names
How do you repress file globbing in “locate”
“\STRING”
Common “locate” options
-A Files that match all patterns
-b just match in the name, not in dir
-c display number of matches
-i ignore case
-q quiet, don’t show errors
-r use regex
-w defaults and is anything in name or dir that matches
syntax for “getent”
getent FILE USER