switch os case unix alias! lf !!ls -CF default alias! lf !!dir/w alias! pwd calc getcwd("!*") alias! save { "Write this file, but only if it has been modified if modified then w!? !* } alias! w { "Write this file, but if readonly then check it out first if readonly && "!?!%!*" == "" then !!co -l % then w!! else !%w!? !* } alias! man { "Display a man page in a new window local b report=0 nosaveregexp magic magicchar=^$.[* let b = newbuffer() (=b) set bd=man (=b)r !!man !* try (=b)1 s/^Reformatting.*ait\.\.\.$// try (=b)% s/\\/\\\\/g try (=b)% s/_\(.\)/\\fI\1\\fR/g try (=b)% s/.\(.\)/\\fB\1\\fR/g try (=b)% s/\\fR\\fB//g try (=b)% s/\\fR\\fI//g (=b)1 i .nf (=b) set nomod (=b)split } alias! kwic { "Build a table showing instances of a word from the manual local d if "!^" == "" then error :kwic missing lhs let d=dirdir(elvispath("elvis.html")) eval split +"kwictweak !^" !!grep -i -n -w !\^ (d/"*.html") } alias! kwictweak { "Convert grep's output to a nice HTML table local ic report=0 magic magicchar=^$.[* try %s/ / /g try %s/ \{2,}/ /g try %s/<[^>]*>//g try %s/&[[:alnum:]]*;//g try v/\/d %s/^\([^:]*\):\([^:]*\):\(.*\)\<\(!\^\)\>\(.*\)$/\3\4<\/a\>\5/ %s/^/ / %s/^[^<]*\([^<]\{30}<.*>.\{0,30}\).*$/\1/ 1 i

Instances of "!^" in elvis' manual

 $ a 
se bd=html mapmode=html nomod dis html 1;/>\=!\^ } alias! text { "Like :tag but for any text in *.c or *.h local tagprg="grep -nsw '(quote(\"'\",$1))' *.[ch] /dev/null \| sed 's/^\\\\\\(.*\\\\\\):\\\\\\(.*\\\\\\):.*/!^ \\1 \\2/'" tag!? !* } alias! btext { "Like :browse but for any text in *.c or *.h local tagprg="grep -nsw '(quote(\"'\",$1))' *.[ch] /dev/null \| sed 's/^\\\\\\(.*\\\\\\):\\\\\\(.*\\\\\\):.*/!^ \\1 \\2/'" browse!! !* } if gui=="x11" then { alias! courier { "Use courier fonts of a given size (X11 only) local s=!(18)1 w=!(medium)2 if !isnumber(s) then error usage: courier [fontsize ["bold"]] let font="*-courier-";w;"-r-*-";s;"-*" let italicfont="*-courier-";w;"-o-*-";s;"-*" if w != "bold" then let boldfont="*-courier-bold-r-*-";s;"-*" } alias! fork { "Run a program in the background (X11 only) !! >/dev/null 2>&1 !* & } alias! theme { "list themes, or load one local a="" i j k d f if "!1" == "" then { for i (1..elvispath[:,0]) do { let d=elvispath[:,i] for f shell("echo" d/"themes/*.ex") do { set k=0 for j a do { if basename(f) == j then set k=1 } if basename(f) != "*" && k == 0 then let a=a basename(f) } } if a == "" then error no themes else calc a } else { source (elvispath("themes/!1.ex")) } } alias! readTHEME { " download a "theme:name" URL local a="ftp://ftp.cs.pdx.edu/pub/elvis/themes_archive" local f nowrapscan magicchar="^$[*." magic report=0 nolock set reol=text bufdisplay=normal " " Read the theme's files, in a single "*.thm" file if "!2" == "" || "!2" == "/" || dirext("!2") != "" then { if "!2" == "" || "!2" == "/" then let f=a/"index.html" else let f=a/"!2" r (f) if strlen("!2") < 2 || tolower(basename("!2")<<4) == ".htm" then { eval %s/index.html/(quote("/~", a))\/&/g eval %s/src="/&(quote("/~", a))\//g set bd=html mapmode=html } else set bd=hex } else { r (a)/!2.thm "ta !2.thm " " Make sure the user's themes directory exists if dirperm($HOME/".elvislib") != "notfile" then !!mkdir ~/.elvislib if dirperm($HOME/".elvislib/themes") != "notfile" then !!mkdir ~/.elvislib/themes " " Extract the theme files %s?^BEGIN \([^.][^[:space:]$/\\!!~]*\)?+;/^END /-w!! \~/.elvislib/themes/\1?x " " Delete the data, but keep any introductory comments 1;/^BEGIN /,$d " " The above steps are not considered to be modifications set nomod " " Load the theme theme !2 } } alias! mktheme { " Create a new theme, in the current buffer local i p f="" magicname wrapscan report=0 if "!1" == "" then error usage: mkthtme name " " put the introductory text into the buffer %d i !1 s/.*/\U&\E\n\nDescribe the theme here. Include your name and any credits.\n/ " " add the ex script for setting up the colors $a BEGIN !1.ex a try set textcursor=opaque eval a color normal (color("normal")) a if color("idle") != "like normal" eval a then color idle (color("idle")) if color("idle") == "like normal" then warning You should probably set the idle colors to something other than "like normal" for i in cursor selection bottom toolbar tool scrollbar scroll statusbar status do { if color(i) == "" then error You need to set the (i) colors else eval a color (i) (color(i)) } a END !1.ex " " add any image files %s/\S\+\.xpm/let f = f "&"/x for i (f) do { try 1;/^BEGIN $i/goto else { eval ("$")a BEGIN (i) if exists(i) then let p = i else let p = elvispath("themes"/i) "Note: The odd method of reading the image files is necessary due to the "fact that sometimes the last line is a comment without a \n terminator. eval r !! cat (p); echo $s/.*/END $i/ } } " " leave the cursor on the line with the comment 3 " " rename the edit buffer. This also displays the new name on the bottom row if filename != "!1.thm" then file !1.thm } } alias! copying split (elvispath("license")) alias! howto { "Search elvis' "How To" appendix. ! makes it try harder. local magic magicchar=^$.[* if "!?" == "!!" then split +/*!1.*!2.*!3.*!4 (elvispath("howto.html")) else split +/^
.*!1.*!2.*!3.*!4 (elvispath("howto.html")) } alias! cbload { "Load cut-buffers from a file local b report=0 magic magicchar=^$.[* let b=buffer if "!1" == "" then error cbload requires a file name e !1 %s:^--CBS-- \([a-z]\)$:+;/^--CBS--/-1 y \1:x eval buffer (b) } alias! cbsave { "Save cut-buffers to a file local a b report=0 let b = buffer if "!1" == "" then error cbsave requires a file name e !1 %d let a = 'a' while a <= 'z' do { if buffer("Elvis cut buffer ";char(a)) then { eval $ a --CBS-- (char(a)) eval $ put (char(a)) } let a = a + 1 } $ a --CBS-- w!? eval buffer (b) } alias! cbshow { "Show contents of cut-buffers local b c i l="!*" q u s if l == "" then let l = "abcdefghijklmnopqrstuvwxyz123456789" echo Buf\| Size & Type \| Contents echo ---+-------------+---------------------------------------------------- for i (1 .. strlen(l)) do { let c = ((l;" ") << i) >> 1 let b = "Elvis cut buffer ";c if buffer(b) then { (=b) let u = putstyle << 4; (=b) let q = u=="char" ? bufchars - 1 : buflines let s = q; " "; u; (q == 1 ? " " : "s") (=b) calc " "; c; " |"; s >> 12; " | "; line(b,1) << 52 } let i = i + 1 } } alias! fe features alias! features { "Describe the configuration of this elvis local i f l calc "Elvis version: ";version set f="normal" for i in syntax hex html man tex do let f=f (feature(i) ? i) calc "Display modes: ";f set f="" let f=f (feature("ftp") ? "ftp") let f=f (feature("http") ? "http") calc "Network protocols: ";(f ? f : "none") set f="" l="Other features: " for i in alias array autocmd backtick browse cachedesc calc complete fold g hlobject hlsearch image incsearch litre lpr make mapdb misc mkexrc normal proto ram rcsid showtag smartargs spell split tags textobj v do { if feature(i) then { if strlen(l;f i) > columns-2 then { calc l;f set l=" " f="" } let f=f i } } if f != "" then calc l;f } alias! customize { "Edit a personal copy of one of elvis' configuration files local d o n f="!^" if f == "" then error :customize requires the name of a configuation file let o = elvispath(f) if o == "" then error "!^" is not a known configuration file if os=="msdos" || os=="os2" || os == "win32" then let d=$HOME/"elvislib" else let d=$HOME/".elvislib" if dirperm(d) == "new" then eval !mkdir "(d)" let n = d / f if exists(n) then e (n) else { e (o) (=o) file (n) (=n)se noro } } alias! left { "Move text to the left side of each line local report=0 magic magicchar=^$.[* !%s/^\s* !%s/\s*$ } alias! right { "Move text to the right side of each line local w report=0 magic magicchar=^$.[* !%left try !%s/ \{2,}/ /g let w = (textwidth == 0) ? columns : textwidth eval !%s/.$/&("" << w) eval !%s/^\\\(.\\{(w)}\\\).*/\\1 !%s/^\(.*[^ ]\)\( \+\)$/\2\1/ } alias! center { "Move text to the center of each line local report=0 magic magicchar=^$.[* !%right !%s/ / /g } alias! rot13 { "Perform rot-13 encryption/decryption local i report=0 magic magicchar=^$.[* for i (0..12) do { try eval !%s/(char(i + 'a'))//g try eval !%s/(char(i + 'n'))/(char(i + 'a'))/g try eval !%s//(char(i + 'n'))/g try eval !%s/(char(i + 'A'))//g try eval !%s/(char(i + 'N'))/(char(i + 'A'))/g try eval !%s//(char(i + 'N'))/g } } alias! cfmt { "Adjust C or C++ comment block. Omit the */ line from range. local report=0 nosaveregexp magic magicchar=^$.[* if !< == !> then error you must invoke cfmt with a range of two or more lines !>a STOP!! try !%s/^\(\s*\)\/\/\s*/\1/ then { "C++ comments, already removed the // !%!!fmt !<,/^STOP!!$/- s/^\s*/&\/\/ / } else { "C comments, still need to remove the /* or * !/\>/g " " Convert uppercase lines into headings try s/^[A-Z0-9][A-Z0-9-.) ]*$/

&<\/h1>/ then set n=text " " Convert horizontal lines into
tags try s/^\s*[-=]\{10,}\s*$/
/ then set n=text " " Try to be clever about finding links try s/http:[^">, )]\+/
&<\/a>/g try s/ftp:[^">, )]\+/&<\/a>/g try s/[a-zA-Z]\w*@[a-zA-Z][[:alnum:].-]\+/&<\/a>/g " " Convert asterisked lines into "ul" list items. try s/^\s*\* */
  • / then set n=ul " " Convert numbered lines (other than headings) into "ol" list items. try s/^\s*\d\+[.)] \+/
  • then set n=ol " " if in normal text, then assume indented text is preformatted. if m=="text" then { try s/^\s/set n=pre/x } " " if in preformatted text, then assume non-indented line ends
     block
      if m=="pre" && n=="pre"
      then {
       try s/^\S/set n=text/x
      }
      "
      " Any non-blank line turns off the "b" flag.
      try s/./set b=false/x
      "
      " if not in formatted text, then blank lines are paragraph breaks.  Avoid
      " consecutive 

    tags, though. if m!="pre" && b=="false" then { try s/^$/

    / then set b=true } " " if mode switched, then add tags for that. if m!=n then { if m!="text" then eval i if n!="text" then eval i <(n)> let m=n set b=false } } " " If converting the whole file, then add ... if "!%" == "" then { $a eval 1i (htmlsafe(filename)) " " minor conveniences... set bufdisplay=html mapmode=html display html eval file (dirdir(filename)/basename(filename)).html } } """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " The following were contributed by Ian Utley (iu@apertus.uk.com) alias! align { "Align any = signs (or other given text) in selected line local f=0 i=0 k report=0 nosaveregexp magic magicchar=^$.[* " " The following if tests to see if we have visually highlighted lines. " if ( !> !!= "" ) then { !< mark a !> mark b let f=1 } if ( f == 1) then { " " Initialise i which will store the alignment column. " Mark the current line to return the cursor at the end. " set i=0 mark z " " Remove any whitespace before the alignment character. " 'a,'b s/[ ]*!(=)\$/!(=)\$/ " " We could be aligning != <= or >= so we want to keep this letter " near. Of course we may not be aligning an equals but we commonly do. " if ( "!(=)\$" == "=" ) then { 'a,'b s/[ ]*\([!!<>]*\)!(=)\$[ ]*/ \1!(=)\$ / } " " let f=0 'a,'bglobal /!(=)\$/ { " " Special case for the top line as -1 will not work. " if ( current("line") == 1 ) then { 1 insert "" let f=1 } -1 /!(=)\$ " " " Remember the largest column number for alignment. " if (current("column")>i) then let i=current("column") " " Special case removal " if ( current("line") > 1 && f == 1) then { 1 delete let f=0 } } " " Do the alignment. " let f=0 'a,'bglobal /!(=)\$/ { " " Special case for the top line as -1 will not work. " if ( current("line") == 1 ) then { 1i "" let f=1 } -1 /!(=)\$ " " Not sure why I need to add +1 " let k=i-current("column")+1 s/\([!!<>]*\)!(=)\$/ \1!(=)\$/ eval s/ *\\\( \{(k)\}[!!<>]*!(=)\$\\\)/\1 " " Special case removal " if ( current("line") > 1 && f == 1 ) then { 1 delete let f=0 } } " " Return the cursor to the line it was previously on. " 'z } } alias! match { "Move to the line where the pairing keyword is located local a b="" d x y i nowrapscan magic magicchar=^$.[* "x and y are lists of matching words -- we'll seek forward from x words "and backward from y words. The words listed here are appropriate for "Unix shell scripts. set x="if/then/case/do/begin/repeat" y="fi/else/esac/done/end/until" let a=current("word") if (a == "") then error Cursor is not on a word while b=="" && x!="." do { if a==dirfile(x) then { let b=dirfile(y) set d=forward } if a==dirfile(y) then { let b=dirfile(x) set d=backward } let x=dirdir(x) let y=dirdir(y) } if ( b=="" ) then error (a) is not a matchable keyword mark c set i=1 if (d=="forward") then { while ( i != 0 ) do { set i=0 try eval /\<(b)\> else { " Failed to locate a match 'c error No matching (b) located } mark d eval 'c,'d global /\<(a)\>/ let i=i+1 eval 'c,'d global /\<(b)\>/ let i=i-1 } } if (d=="backward") then { while ( i != 0 ) do { set i=0 try eval ?\<(b)\> else { " Failed to find a match 'c error No matching (b) located } mark d eval 'd,'c global /\<(a)\>/ let i=i+1 eval 'd,'c global /\<(b)\>/ let i=i-1 " global command has moved cursor back to 'c 'd } } }