The last cheat sheet I posted was in need of revision and reordering. This one is better than the last--I hope.  CHEAT SHEET OF SAM COMMANDS x cmd - set dot and run command on each matching line . -- apply command to dot , -- apply command to whole document < replace dot with std input of command ! run the unix command > send dot to std input of command 0spell -- check spelling >wc -l -- count just the lines >wc -- do a line, word and character count |tr a-z A-Z -- change case ,x/".+"/ y/"/ | tr [:lower:] [:upper:] OR ,x/".+"/ y/"/ | tr a-z A-Z -- to capitalise all letters inside quotes s/.*/*&*/ -- enclose phrase in asterisks |fold -s -- break up/format long lines |fmt -- idem |sort -- sort the file |uniq -- delete juxtaposed duplicate lines |awk '!seen[$0]++' -- delete non-juxtaposed duplicate lines ,x/\n+/a/\n/ -- finds every occurrence of 1 or more (+) newlines (\n) and appends a new line. /vi/ or +/vi/ -- search forward 0/regex/ -- search from beg. of file forwards 0/regex/+-p -- search for a string and select the whole line that contains it /vi/+- m 0 selects and moves the next line containing "vi" to the top of the file /vi/+- t 0 selects and copies the next line with "vi" to the top of the file $/regex/ -- search from end of the file backwards Search for a string, and then go from search results in sam window to document: ,x g/hello/{ p } 0,$ t "peter.c" 0 -- copy contents of one to another , and ; selects whole document , equivalent to 0,$ 0;5 and 0,5 - selects 1st five lines -/^/+#10 -- go to 10th column of current line B < echo *.org -- One can load multiple files by using < B < grep -l vi * will load only those files that contain the string "vi" D is the complement of B. It eradicates the file from sam's memory but does not delete the file from disk! Without a name argument removes current file e replaces current file with one specified f changes the filename f /d -- strip from all files X ,x/(.+\n)+/ g/account/+-p -- look through every file, and every line, and if any line contains "account" print it out in sam window s/.*/& Hello/ -- add " Hello" to the end of line s/good/bad/ The y command *excludes from consideration* in the seach that follows. ,y/ben/ x/(.+\n)+/g/Directory details/p Y/regexp/ command -- Exclude the file named by "regex" from consideration. .x g/fred/ v/........./ c/jim/ -- Look through dot. If dot contains "fred" change it to "jim" provided it is not "fred....." ,x[a-zA-Z]+/{ g/fred/ v/...../ c/jim/ g/jim/ v/..../ c/fred/ } In the above command braces {} allow for multiple commands. The command says: search every line that contains 1 or more letters, if the line contains "fred" change it to "jim" and if "jim" change it to fred, provided "fred" is not "fred." and "jim" not "jim." g - "if" v" - "if not, unless the regex is" ,| ssam -f your_script -- apply a sam script ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T5a59d8c3b404b14d-Mcbaa0122bf6dba5f8794b600 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription