Newsgroups: comp.editors


I collected so many nifty vi macros that I eventually forgot what each
key did.  So here is a way that I organized my .exrc to keep everything
documented, and to create an on-line help reference.

First thing is to put a descriptive line above every macro.
Each descriptive line starts with the string: <"HINT:>.

Here's a snippet of my .exrc:


--------------start of a few examples --------------------
" ------------------------------------------------------------
"HINT:'F'               Formats a paragraph
"
map F !}fmt ^[
" ------------------------------------------------------------
"HINT:'#'               toggles between numbered editing and non-numbered
"
map @NU@ :set nu^M:map # @NONU@^M:^M
map @NONU@ :set nonu^M:map # @NU@^M:^M
map # @NU@
" ------------------------------------------------------------
--------------end of a few examples --------------------



Next,  you create a macro that collects out the "HINT: lines and
puts them on the screen for your perusal:



" -------------------------------------------------------------
"HINT:'H'               print helpful hints
map H :! clear; sed -n -e "s/^\"HINT://p" ~/.exrc^M
" -------------------------------------------------------------


Now, I can just hit 'H' from command mode and get the following
reminder screen:

------------------------------------------------------------------
'H'             print helpful hints
'^Z'            background editor in input mode. autowrite is set.
'^O'            begin a C-style block, leaving in insert mode
'^}'            take you past end of block, leaving in insert mode
'<ext>='        inserts comment during insert mode
'<ext>='        comments current line during command mode
'<ext>-'        deletes comment characters during command mode
'F'             Formats a paragraph
'#'             toggles between numbered editing and non-numbered
'^I'            toggles between autoindent and noautoindent
'T'             command will toggle between 4 stop and 8 stop tabs...
'S'             spell checks an entire document using ispell
'^X'            executes the current line of text
'^P'            Sort by paragraphs...
'X'             make and delete ruler line (toggle)
'V'             add modelines to top of file
Kompletion macros...
	type partial word followed by ^K, and choices of
	completed words will be offered.  ^N is next ^P previous...
------------------------------------------------------------------

Typing <return> puts me back in vi.

You could also put a bunch of <HELP:> lines in the file to remind
you of other infrequently used built-in commands.

Have fun!
--
Rick


Attached is a uuencoded copy of my .exrc:

-------------------- cut here -----------------------------
begin 664 .exrc.new
M(B M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM"B)(24Y4.@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