From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FORGED_GMAIL_RCVD,FREEMAIL_FROM,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29221 invoked from network); 31 Aug 2021 05:53:19 -0000 Received: from tb-ob1.topicbox.com (64.147.108.173) by inbox.vuxu.org with ESMTPUTF8; 31 Aug 2021 05:53:19 -0000 Received: from tb-mx1.topicbox.com (tb-mx1.nyi.icgroup.com [10.90.30.61]) by tb-ob1.topicbox.com (Postfix) with ESMTP id 23A3225BDB for ; Tue, 31 Aug 2021 01:53:16 -0400 (EDT) (envelope-from bounce.mMcbaa0122bf6dba5f8794b600.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx1.topicbox.com (Postfix, from userid 1132) id 1740A35A7393; Tue, 31 Aug 2021 01:53:16 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=from:to :message-id:date:mime-version:content-type :content-transfer-encoding:list-help:list-id:list-post :list-subscribe:reply-to:subject:list-unsubscribe; s=dkim-1; bh= LaPlGI4zn95vNmj3coDgLkdAHmJJZxh0oXfgxy/XHXY=; b=QlW3RciGHFN0YFKx qUuJ1OvE2O0akkCqxZIE+35HyZ+Jg/VXS1Odgs4Kfh/R61zNnpemv0iEIw4DSZKr SPPrLwiupgKDBXbz5p9s17bOGsC7ykCabQEpnsCzBu3vNOxI9F6oWjnu0NI/SfUn PjhKm5Trrq2J2GdkkpsBKSXwcAY= From: revcomninos@gmail.com To: 9fans <9fans@9fans.net> Message-Id: <16303891900.ad7cb5c.65212@composer.9fans.topicbox.com> Date: Tue, 31 Aug 2021 01:53:10 -0400 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="16303891901.d719F20bA.65212" Content-Transfer-Encoding: 7bit Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: b8f2c50e-0a1f-11ec-a9fa-299f9134e1fa Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UNWE1OWQ4YzNiNDA0YjE0ZC1NY2JhYTAxMjJiZjZkYmE1Zjg3OTRi?= =?UTF-8?B?NjAwPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> Subject: [9fans] Revised sam cheat sheat List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:Mcbaa0122bf6dba5f8794b600:1:p6xKQg5G2EYuZKbhIkNqGMEN_VGUzfOhJgYVfrCCXKw --16303891901.d719F20bA.65212 Date: Tue, 31 Aug 2021 01:53:10 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The last cheat sheet I posted was in need of revision and reordering. This = one is better than the last--I hope.=C2=A0 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-Mcbaa0= 122bf6dba5f8794b600 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription --16303891901.d719F20bA.65212 Date: Tue, 31 Aug 2021 01:53:10 -0400 MIME-Version: 1.0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Th= e last cheat sheet I posted was in need of revision and reordering. This on= e is better than the last--I hope. 


CHEAT S= HEET OF SAM COMMANDS

x cmd = - set dot and run command on each matching line

. -- apply command to dot

, -- apply co= mmand to whole document

< replace dot with std input of command

! run the unix command

> send dot= to std input of command


0<date -- insert date

>spell -- che= ck 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/&= quot;.+"/ y/"/ | tr a-z A-Z

-- to capitalise all letters inside quotes


s/.*/*&*/ -- enclose phrase in asterisks


|fold -s -- b= reak 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/rege= x/ -- 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 selec= ts 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

=3D

}


0,$ t "peter.c" 0 -- copy contents of one to another


, an= d ; selects whole document

, equi= valent 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 <nl? --= set the current filename to null

n gives a list of read and loaded files


{} Braces group commands

[ˆn] an= y char but n

[nm] n o= r m


w writes the whole file, or parts of a file to disk

< cat /home/red/bin/songs -- insert contents of a file

r /home/red/bin/songs -- idem

r replaces dot in the current file with the contents of the file specified


< /home/red/bin/songs -- insert contents of a script

> /home/red/bin/pass google -- output contents of script to sam window
<= p style=3D"margin-bottom:0cm;line-height:100%;">

< echo "Hello world" -- insert ascii code at the current position


x/^/a/ / -- indent the selected text by 1 tab. x means apply to all lines in the selection.


sam terminal information

---------= --------------

. indi= cates the current file

+ the fi= le has a window open

- the fil= e has been read by sam

* the fil= e is open in more than one instance

' the loaded file differs from the file on disk


/.+\n/ -- f= inds lines with text

/.*\n= / -- matches single whole lines

0/Ben/,/Son/ -- find a range of text

.,/re= gexp/ -- selects text FROM dot to the regex

./regexp// -- selects the second occurrence of a regex

./regexp// --=20 selects the third occurrence of a regex

/vi/+/vi/ -- search for the second occurrence of "vi" following dot


p -- prints contents of dot in sam terminal

=3D -- prints current value of dot in sam terminal


,t "jun= k" 0 -- copy current file to start of file "junk"


Perform conditional ACTIONS on lines:

g/r= egexp/ command -- g =3D if. If dot contains regexp, run command

g/test/d

,x g/vi/p -- if a line has "vi" print the line in sam window

v/regexp/ command -- If dot does not contain, run a command

,x/.*\n/ g/ed/ v/red/ p -- find lines with ed but not red

,x/".+"/ y/"/ -- search for text in quotes but do not show lines with "y&q= uot;

,x/".+"= ;/ x/"/ -- search for text between quotes and only show the quotes
<= p style=3D"margin-bottom:0cm;line-height:100%;">,x /.*\n/ g/vi/ p - break file into lines, if lines contain "vi, print


,x/ +$/d -- delete empty whitespace at end of every line

,x/'+$/i/ --color-auto/ -- insert the phrase "--color-auto" into every line that ends in 1 or more '


.= x/Peter/d -- search dot for 'Peter' and delete 'Peter'

,x/\\v|\\c|\\s1|\\q1/d -- multiple deletions

,x/\*/d -- delete all asterisks

,x/^ /d= -- delete the indents

,x/^ +/d = -- delete all blank spaces at beginning of lines

,x/^$\n/d -- delete all blank lines

,x/\n= \n\n+/c/\n -- change multiple blank lines into 1 blank line


,x/[0-9]/d -- delete lines with numbers

,x/^http.[^,]*?/d -- search for "http...," and delete


C-i -- create a tab stop of 8 spaces

,x/^= /a/ / -- indents text with a tab stop.

x/^ /d -- remove 1 tab of indent from selection


,x/[‘&= lsquo;’’“”‘’]/c/" -- change all smart quotes into straight ones

,x/".+"/ x/"/ c/'/ -- change double quotes (that surround one or more characters) to single quotes

,x/good/ c/bad/ -- change "good" to "bad" on every line

,x/teh/c/the/

,x/Emacs/x/E/c/e/ - change all the capital "E"s in "Emacs" to lower case "e"s

<= br />

X -- is an iterator that works on files not lines

X D -- remove out all up to date files

= X/regexp/ command -- Run command on files whose menu line matches

X/questions/D -- close file called "questions"

X/\.sam$/,x/the/+-p -- search multiple files for text and print the results

X/.*/,x/<cr>/d -- strip <cr> 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 co= mmand *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


= --16303891901.d719F20bA.65212--