Switch to recommended form of GPLv3 permissions notice.
[emacs.git] / etc / refcards / viperCard.tex
blob9db150e9c0ccae7d99557bec0bc9893379d19dae
1 % ViperCard -- The Reference Card for Viper under GNU Emacs 21 and XEmacs 20
2 %**start of header
3 \newcount\columnsperpage
5 % This file can be printed with 1 or 2 columns per page (see below).
6 % Specify how many you want here.
8 \columnsperpage=2
10 % PDF output layout. 0 for A4, 1 for letter (US), a `l' is added for
11 % a landscape layout.
13 \input pdflayout.sty
14 \pdflayout=(1)
16 % Nothing else needs to be changed.
17 % Copyright (C) 1995, 1996, 1997, 2001, 2002, 2003, 2004,
18 % 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
20 % This file is part of GNU Emacs.
22 % GNU Emacs is free software; you can redistribute it and/or modify
23 % it under the terms of the GNU General Public License as published by
24 % the Free Software Foundation; either version 3, or (at your option)
25 % any later version.
27 % GNU Emacs is distributed in the hope that it will be useful,
28 % but WITHOUT ANY WARRANTY; without even the implied warranty of
29 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 % GNU General Public License for more details.
32 % You should have received a copy of the GNU General Public License
33 % along with GNU Emacs; see the file COPYING. If not, write to
34 % the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
35 % Boston, MA 02110-1301, USA.
37 % This file is intended to be processed by plain TeX (TeX82).
39 % The final reference card has six columns, three on each side.
40 % This file can be used to produce it in any of three ways:
41 % 1 column per page
42 % produces six separate pages, each of which needs to be reduced to 80%.
43 % This gives the best resolution.
44 % 2 columns per page
45 % produces three already-reduced pages.
46 % You will still need to cut and paste.
47 % 3 columns per page
48 % produces two pages which must be printed sideways to make a
49 % ready-to-use 8.5 x 11 inch reference card.
50 % For this you need a dvi device driver that can print sideways.
51 % Which mode to use is controlled by setting \columnsperpage above.
53 % Author of Viper:
54 % Michael Kifer
55 % email: kifer@cs.sunysb.edu
57 % Author of VIP 4.3:
58 % Aamod Sane
59 % email: sane@cs.uiuc.edu
61 % Author of VIP 3.5:
62 % Masahiko Sato
63 % email: ms@sail.stanford.edu
65 % The original TeX code for formatting the reference card was written by:
66 % Stephen Gildea
67 % UUCP: mit-erl!gildea
68 % email: gildea@stop.mail-abuse.org
71 \def\versionnumber{3.0}
72 \def\year{2008}
73 \def\version{August 2006 v\versionnumber}
75 \def\shortcopyrightnotice{\vskip 1ex plus 2 fill
76 \centerline{\small \copyright\ \year\ Free Software Foundation, Inc.
77 Permissions on back. v\versionnumber}}
79 \def\copyrightnotice{
80 %\vskip 1ex plus 2 fill\begingroup\small
81 \vskip 1ex \begingroup\small
82 \centerline{Copyright \copyright\ \year\ Free Software Foundation, Inc.}
83 \centerline{by Michael Kifer, Viper \version}
84 \centerline{by Aamod Sane, VIP version 4.3}
85 \centerline{by Masahiko Sato, VIP version 3.5}
87 Permission is granted to make and distribute copies of
88 this card provided the copyright notice and this permission notice
89 are preserved on all copies.
91 For copies of the GNU Emacs manual, write to the Free Software
92 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
94 \endgroup}
96 % make \bye not \outer so that the \def\bye in the \else clause below
97 % can be scanned without complaint.
98 \def\bye{\par\vfill\supereject\end}
100 \newdimen\intercolumnskip
101 \newbox\columna
102 \newbox\columnb
104 \def\ncolumns{\the\columnsperpage}
106 \message{[\ncolumns\space
107 column\if 1\ncolumns\else s\fi\space per page]}
109 \def\scaledmag#1{ scaled \magstep #1}
111 % This multi-way format was designed by Stephen Gildea
112 % October 1986.
113 % Slightly modified by Masahiko Sato, September 1987.
114 \if 1\ncolumns
115 \hsize 4in
116 \vsize 10in
117 %\voffset -.7in
118 \voffset -.57in
119 \font\titlefont=\fontname\tenbf \scaledmag3
120 \font\headingfont=\fontname\tenbf \scaledmag2
121 \font\miniheadingfont=\fontname\tenbf \scaledmag1 % masahiko
122 \font\smallfont=\fontname\sevenrm
123 \font\smallsy=\fontname\sevensy
125 \footline{\hss\folio}
126 \def\makefootline{\baselineskip10pt\hsize6.5in\line{\the\footline}}
127 \else
128 %\hsize 3.2in
129 %\vsize 7.95in
130 \hsize 3.41in % masahiko
131 \vsize 8in % masahiko
132 \hoffset -.75in
133 \voffset -.745in
134 \font\titlefont=cmbx10 \scaledmag2
135 \font\headingfont=cmbx10 \scaledmag1
136 \font\miniheadingfont=cmbx10 % masahiko
137 \font\smallfont=cmr6
138 \font\smallsy=cmsy6
139 \font\eightrm=cmr8
140 \font\eightbf=cmbx8
141 \font\eightit=cmti8
142 \font\eightsl=cmsl8
143 \font\eighttt=cmtt8
144 \font\eightsy=cmsy8
145 \textfont0=\eightrm
146 \textfont2=\eightsy
147 \def\rm{\eightrm}
148 \def\bf{\eightbf}
149 \def\it{\eightit}
150 \def\sl{\eightsl} % masahiko
151 \def\tt{\eighttt}
152 \normalbaselineskip=.8\normalbaselineskip
153 \normallineskip=.8\normallineskip
154 \normallineskiplimit=.8\normallineskiplimit
155 \normalbaselines\rm %make definitions take effect
157 \if 2\ncolumns
158 \let\maxcolumn=b
159 \footline{\hss\rm\folio\hss}
160 \def\makefootline{\vskip 2in \hsize=6.86in\line{\the\footline}}
161 \else \if 3\ncolumns
162 \let\maxcolumn=c
163 \nopagenumbers
164 \else
165 \errhelp{You must set \columnsperpage equal to 1, 2, or 3.}
166 \errmessage{Illegal number of columns per page}
167 \fi\fi
169 %\intercolumnskip=.46in
170 \intercolumnskip=.19in % masahiko .19x4 + 3.41x3 = 10.99
171 \def\abc{a}
172 \output={%
173 % This next line is useful when designing the layout.
174 %\immediate\write16{Column \folio\abc\space starts with \firstmark}
175 \if \maxcolumn\abc \multicolumnformat \global\def\abc{a}
176 \else\if a\abc
177 \global\setbox\columna\columnbox \global\def\abc{b}
178 %% in case we never use \columnb (two-column mode)
179 \global\setbox\columnb\hbox to -\intercolumnskip{}
180 \else
181 \global\setbox\columnb\columnbox \global\def\abc{c}\fi\fi}
182 \def\multicolumnformat{\shipout\vbox{\makeheadline
183 \hbox{\box\columna\hskip\intercolumnskip
184 \box\columnb\hskip\intercolumnskip\columnbox}
185 \makefootline}\advancepageno}
186 \def\columnbox{\leftline{\pagebody}}
188 \def\bye{\par\vfill\supereject
189 \if a\abc \else\null\vfill\eject\fi
190 \if a\abc \else\null\vfill\eject\fi
191 \end}
194 % we won't be using math mode much, so redefine some of the characters
195 % we might want to talk about
196 \catcode`\^=12
197 \catcode`\_=12
199 \chardef\\=`\\
200 \chardef\{=`\{
201 \chardef\}=`\}
203 \hyphenation{mini-buf-fer}
205 \parindent 0pt
206 \parskip 1ex plus .5ex minus .5ex
208 \def\small{\smallfont\textfont2=\smallsy\baselineskip=.8\baselineskip}
210 \outer\def\newcolumn{\vfill\eject}
212 \outer\def\title#1{{\titlefont\centerline{#1}}\vskip 1ex plus .5ex}
214 \outer\def\section#1{\par\filbreak
215 \vskip 3ex plus 2ex minus 2ex {\headingfont #1}\mark{#1}%
216 \vskip 2ex plus 1ex minus 1.5ex}
218 % masahiko
219 \outer\def\subsection#1{\par\filbreak
220 \vskip 2ex plus 2ex minus 2ex {\miniheadingfont #1}\mark{#1}%
221 \vskip 1ex plus 1ex minus 1.5ex}
223 \newdimen\keyindent
225 \def\beginindentedkeys{\keyindent=1em}
226 \def\endindentedkeys{\keyindent=0em}
227 \endindentedkeys
229 \def\paralign{\vskip\parskip\halign}
231 \def\<#1>{$\langle${\rm #1}$\rangle$}
233 \def\kbd#1{{\tt#1}\null} %\null so not an abbrev even if period follows
235 \def\beginexample{\par\leavevmode\begingroup
236 \obeylines\obeyspaces\parskip0pt\tt}
237 {\obeyspaces\global\let =\ }
238 \def\endexample{\endgroup}
240 \def\key#1#2{\leavevmode\hbox to \hsize{\vtop
241 {\hsize=.75\hsize\rightskip=1em
242 \hskip\keyindent\relax#1}\kbd{#2}\hfil}}
244 \newbox\metaxbox
245 \setbox\metaxbox\hbox{\kbd{M-x }}
246 \newdimen\metaxwidth
247 \metaxwidth=\wd\metaxbox
249 \def\metax#1#2{\leavevmode\hbox to \hsize{\hbox to .75\hsize
250 {\hskip\keyindent\relax#1\hfil}%
251 \hskip -\metaxwidth minus 1fil
252 \kbd{#2}\hfil}}
254 \def\fivecol#1#2#3#4#5{\hskip\keyindent\relax#1\hfil&\kbd{#2}\quad
255 &\kbd{#3}\quad&\kbd{#4}\quad&\kbd{#5}\cr}
257 \def\fourcol#1#2#3#4{\hskip\keyindent\relax#1\hfil&\kbd{#2}\quad
258 &\kbd{#3}\quad&\kbd{#4}\quad\cr}
260 \def\threecol#1#2#3{\hskip\keyindent\relax#1\hfil&\kbd{#2}\quad
261 &\kbd{#3}\quad\cr}
263 \def\twocol#1#2{\hskip\keyindent\relax\kbd{#1}\hfil&\kbd{#2}\quad\cr}
265 \def\twocolkey#1#2#3#4{\hskip\keyindent\relax#1\hfil&\kbd{#2}\quad&\relax#3\hfil&\kbd{#4}\quad\cr}
267 %**end of header
269 \beginindentedkeys
271 \title{ViperCard: Viper Reference Pal}
273 \centerline{(Version 3.0 (Polyglot) for Emacs 21 and XEmacs 20)}
275 %\copyrightnotice
277 \section{Loading Viper}
279 Just type \kbd{M-x viper-mode} followed by \kbd{RET}
281 OR put
283 (setq viper-mode t)
284 (require 'viper)
286 in .emacs
288 \section{Viper States}
290 Viper has four states: {\it emacs state}, {\it vi state}, {\it insert state},
291 {\it replace state}.
292 Mode line tells you which state you are in.
293 In emacs state you can do all the normal GNU Emacs editing.
294 This card explains only vi state and insert state (replace state is similar
295 to insert state).
296 {\bf GNU Emacs Reference Card} explains emacs state.
297 You can switch states as follows.
299 \key{from emacs state to vi state}{C-z}
300 \key{from vi state to emacs state}{C-z}
301 \key{from vi state to emacs state for 1 command}{$\backslash$}
302 \metax{from vi state to insert state}{i, I, a, A, o, O}
303 \metax{from vi state to replace state}{c, C, R}
304 \key{from insert or replace state to vi state}{ESC}
305 \key{from insert state to vi state for 1 command}{C-z}
308 \section{Insert Mode}
309 You can do editing in insert state.
311 \metax{go back to vi state}{ESC}
312 \metax{delete previous character}{C-h, DEL}
313 \key{delete previous word}{C-w}
314 \key{delete line word}{C-u}
315 \key{indent shiftwidth forward}{C-t}
316 \key{indent shiftwidth backward}{C-d}
317 \key{delete line word}{C-u}
318 \key{quote following character}{C-v}
319 \key{emulate Meta key in emacs state}{C-$\backslash$}
320 \key{escape to Vi state for one command}{C-z}
322 \vskip 2mm
324 {\bf The rest of this card explains commands in {\bf vi state}.}
326 \section{Getting Information on Viper}
328 Execute info command by typing \kbd{M-x info} and select menu item
329 \kbd{viper}. Also:
331 \key{describe function attached to the key {\it x}}{$\backslash$ C-h k {\it x}}
333 \section{Leaving Emacs}
335 \metax{suspend Emacs}{:st {\rm or} :su}
336 \metax{exit Emacs permanently}{C-xC-c}
337 \metax{exit current file}{:wq {\rm or} :q}
339 \shortcopyrightnotice
341 \section{Error Recovery}
343 \metax{abort command}{C-c (user level = 1)}
344 \metax{abort command}{C-g (user level > 1)}
345 \key{redraw messed up screen}{C-l}
346 \metax{{\bf recover} after system crash}{:rec file}
347 \metax{restore a buffer }{:e!\ {\rm or} M-x revert-buffer}
350 \section{Counts}
352 Most commands in vi state accept a {\it count} which can be supplied as a
353 prefix to the commands. In most cases, if a count is given, the
354 command is executed that many times. E.g., \kbd{5 d d} deletes 5
355 lines.
357 \section{Registers}
359 There are 26 registers (\kbd{a} to \kbd{z}) that can store texts
360 and marks.
361 You can append a text at the end of a register (say \kbd{x}) by
362 specifying the register name in capital letter (say \kbd{X}).
363 There are also 9 read only registers (\kbd{1} to \kbd{9}) that store
364 up to 9 previous changes.
365 We will use {\it x\/} to denote a register.
366 \section{Entering Insert Mode}
368 \key{{\bf insert} at point}{i}
369 \key{{\bf append} after cursor}{a}
370 \key{{\bf insert} before first non-white}{I}
371 \key{{\bf append} at end of line}{A}
372 \key{{\bf open} line below}{o}
373 \key{{\bf open} line above}{O}
375 \section{Buffers and Windows}
377 \key{move cursor to {\bf next} window}{C-x o}
378 \key{delete current window}{C-x 0}
379 \key{delete other windows}{C-x 1}
380 \key{split current window into two windows}{C-x 2}
381 \key{{\bf switch} to a buffer in the current window}{C-x {\sl buffer}}
382 \metax{{\bf switch} to a buffer in another window}{:n, :b, {\rm or} C-x 4 {\sl buf}}
383 \key{{\bf kill} a buffer}{:q! {\rm or} C-x k}
384 \key{list existing {\bf buffers}}{:args {\rm or} C-x b}
386 \section{Files}
388 \metax{{\bf visit} file in the current window}{v {\sl file} {\rm or} :e {\sl file}}
389 \key{{\bf visit} file in another window}{V {\sl file}}
390 \key{{\bf visit} file in another frame}{C-v {\sl file}}
391 \key{{\bf save} buffer to the associated file}{:w {\rm or} C-xC-s}
392 \metax{{\bf write} buffer to a specified file}{:w {\sl file} {\rm or} C-xC-w}
393 \metax{{\bf insert} a specified file at point}{:r {\sl file} {\rm or} C-xi}
394 \key{{\bf get} information on the current {\bf file}}{C-c g {\rm or} :f}
395 \key{run the {\bf directory} editor}{:e RET {\rm or} C-xd}
397 %\shortcopyrightnotice
399 \section{Viewing the Buffer}
401 \key{scroll to next screen}{C-f}
402 \key{scroll to previous screen}{C-b}
403 \key{scroll {\bf down} half screen}{C-d}
404 \key{scroll {\bf up} half screen}{C-u}
405 \key{scroll down one line}{C-e}
406 \key{scroll up one line}{C-y}
408 \key{put current line on the {\bf home} line}{z H {\rm or} z RET}
409 \key{put current line on the {\bf middle} line}{z M {\rm or} z .}
410 \key{put current line on the {\bf last} line}{z L {\rm or} z -}
412 \section{Marking and Returning}
414 \key{{\bf mark} point in register {\it x}}{m {\it x}}
415 \key{set mark at buffer beginning}{m <}
416 \key{set mark at buffer end}{m >}
417 \key{set mark at point}{m .}
418 \key{jump to mark}{m ,}
419 \key{exchange point and mark}{` `}
420 \key{... and skip to first non-white on line}{' '}
421 \key{go to mark {\it x}}{` {\it x}}
422 \key{... and skip to first non-white on line}{' {\it x}}
423 \key{view contents of marker {\it x}}{[ {\it x}}
424 \key{view contents of register {\it x}}{] {\it x}}
426 \section{Macros}
428 Emacs style macros:
430 \key{start remembering keyboard macro}{C-x (}
431 \key{finish remembering keyboard macro}{C-x )}
432 \key{call last keyboard macro}{*}
434 \key{start remembering keyboard macro}{@ \#}
435 \key{finish macro and put into register {\it x}}{@ {\it x}}
436 \key{execute macro stored in register {\it x}}{@ {\it x}}
437 \key{repeat last @{\it x} command}{@ @}
439 \key{Pull last macro into register {\it x}}{@ ! {\it x}}
441 Vi-style macros (keys to be hit in quick succession):
443 \key{define Vi-style macro for Vi state}{:map}
444 \key{define Vi-style macro for Insert state}{:map!}
446 \key{toggle case-sensitive search}{//}
447 \key{toggle regular expression search}{///}
448 \key{toggle `\%' to ignore parentheses inside comments}{\%\%\%}
451 \section{Motion Commands}
453 \key{go backward one character}{h {\rm or} C-h}
454 \key{go forward one character}{l}
455 \metax{next line keeping the column}{j {\rm or} LF {\rm or} C-n}
456 \key{previous line keeping the column}{k}
457 \metax{next line at first non-white}{+ {\rm or} RET {\rm or} C-p}
458 \key{previous line at first non-white}{-}
460 \key{beginning of line}{0}
461 \key{first non-white on line}{^}
462 \key{end of line}{\$}
463 \key{go to {\it n}-th column on line}{{\it n} |}
465 \key{go to {\it n}-th line}{{\it n} G}
466 \key{go to last line}{G}
467 \key{find matching parenthesis for \kbd{()}, \kbd{\{\}} and \kbd{[]}}{\%}
469 \key{go to {\bf home} window line}{H}
470 \key{go to {\bf middle} window line}{M}
471 \key{go to {\bf last} window line}{L}
473 \subsection{Words, Sentences, Paragraphs, Headings}
475 \key{forward {\bf word}}{w {\rm or} W}
476 \key{{\bf backward} word}{b {\rm or} B}
477 \key{{\bf end} of word}{e {\rm or} E}
479 In the case of capital letter commands, a word is delimited by a
480 non-white character.
482 \key{forward sentence}{)}
483 \key{backward sentence}{(}
485 \key{forward paragraph}{\}}
486 \key{backward paragraph}{\{}
488 \key{forward heading}{]]}
489 \key{backward heading}{[[}
490 \key{end of heading}{[]}
492 \subsection{Find Characters on the Line}
494 \key{{\bf find} {\it c} forward on line}{f {\it c}}
495 \key{{\bf find} {\it c} backward on line}{F {\it c}}
496 \key{up {\bf to} {\it c} forward on line}{t {\it c}}
497 \key{up {\bf to} {\it c} backward on line}{T {\it c}}
498 \key{repeat previous \kbd{f}, \kbd{F}, \kbd{t} or \kbd{T}}{;}
499 \key{... in the opposite direction}{,}
501 %\newcolumn
502 %\title{Viper Quick Reference Card}
504 \section{Searching and Replacing}
506 \key{search forward for {\sl pat}}{/ {\sl pat}}
507 \key{search backward with previous {\sl pat}}{?\ RET}
508 \key{search forward with previous {\sl pat}}{/ RET}
509 \key{search backward for {\sl pat}}{?\ {\sl pat}}
510 \key{repeat previous search}{n}
511 \key{... in the opposite direction}{N}
513 \key{{\bf query} replace}{Q}
514 \key{{\bf replace} a character by another character {\it c}}{r {\it c}}
515 \key{{\bf overwrite} {\it n} lines}{{\it n} R}
517 \metax{{\bf buffer} search (if enabled)}{g {\it move command}}
519 \section{Modifying Commands}
521 Most commands that operate on text regions accept the motion commands,
522 to describe regions. They also accept the Emacs region specifications
523 {\bf r} and {\bf R}. {\bf r} describes the region between {\it point}
524 and {\it mark}, and {\bf R} describes whole lines in that region.
525 Motion commands are classified into {\it point commands} and
526 {\it line commands}. In the case of line commands, whole lines will
527 be affected by the command.
529 The point commands are as follows:
531 \hskip 5ex
532 \kbd{h l 0 ^ \$ w W b B e E ( ) / ?\ ` f F t T \% ; ,}
534 The line commands are as follows:
536 \hskip 5ex
537 \kbd{j k + - H M L \{ \} G '}
539 These region specifiers will be referred to as {\it m} below.
541 \subsection{Delete/Yank/Change Commands}
543 \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\tabskip=0pt&#\tabskip=0pt&#\cr
544 \fourcol{}{{\bf delete}}{{\bf yank}}{{\bf change}}
545 \fourcol{region determined by {\it m}}{d {\it m}}{y {\it m}}{c {\it m}}
546 \fourcol{... into register {\it x}}{" {\it x\/} d {\it m}}{" {\it x\/} y {\it m}}{" {\it x\/} c {\it m}}
547 \fourcol{a line}{d d}{Y {\rm or} y y}{c c}
548 \fourcol{current {\bf region}}{d r}{y r}{c r}
549 \fourcol{expanded {\bf region}}{d R}{y R}{c R}
550 \fourcol{to end of line}{D}{y \$}{c \$}
551 \fourcol{a character after point}{x}{y l}{c l}
552 \fourcol{a character before point}{DEL}{y h}{c h}
555 \vskip 2ex
556 \key{Overwrite {\it n} lines}{{\it n} R}
558 \subsection{Put Back Commands}
560 Deleted/yanked/changed text can be put back by the following commands.
562 \key{{\bf Put} back at point/above line}{P}
563 \key{... from register {\it x}}{" {\it x\/} P}
564 \key{{\bf put} back after point/below line}{p}
565 \key{... from register {\it x}}{" {\it x\/} p}
567 \subsection{Repeating and Undoing Modifications}
569 \key{{\bf undo} last change}{u {\rm or} :und}
570 \key{repeat last change}{.\ {\rm (dot)}}
572 Undo is undoable by \kbd{u} and repeatable by \kbd{.}.
573 For example, \kbd{u...} will undo 4 previous changes.
574 A \kbd{.} after \kbd{5dd} is equivalent to \kbd{5dd},
575 while \kbd{3.} after \kbd{5dd} is equivalent to \kbd{3dd}.
577 \section{Miscellaneous Commands}
579 \endindentedkeys
581 \paralign to \hsize{#\tabskip=5pt plus 1 fil&#\tabskip=0pt&#\tabskip=0pt&#\tabskip=0pt&#\cr
582 \fivecol{}{{\bf shift left}}{{\bf shift right}}{{\bf filter shell command}}{{\bf indent}}
583 \fivecol{region}{< {\it m}}{> {\it m}}{!\ {\it m\/} {\sl shell-com}}{= {\it m}}
584 \fivecol{line}{< <}{> >}{!\ !\ {\sl shell-com}}{= =}
587 \key{{\bf join} lines}{J}
588 \key{toggle case (takes count)}{\~{}}
590 \key{view register {\it x}}{] {\it x}}
591 \key{view marker {\it x}}{] {\it x}}
593 \key{lowercase region}{\# c {\it m}}
594 \key{uppercase region}{\# C {\it m}}
595 \key{execute last keyboard macro on each line in the region}{\# g {\it m}}
597 \key{insert specified string for each line in the region}{\# q {\it m}}
598 \key{check spelling of the words in the region}{\# s {\it m}}
600 \key{repeat previous ex substitution}{\&}
601 \key{change to previous file}{C-^}
603 \key{Viper Meta key}{_}
605 \section{Customization}
607 By default, search is case sensitive.
608 You can change this by including the following line in your \kbd{\~{}/.vip} file.
610 \hskip 5ex
611 \kbd{(setq viper-case-fold-search t)}
613 The following is a subset of the variety of
614 options available for customizing Viper.
615 See the Viper manual for details on these and other options.
617 \beginindentedkeys
619 \paralign to \hsize{#\tabskip=10pt plus 1 fil&#\tabskip=0pt&#\cr
620 \twocol{{\bf variable}}{{\bf default value}}
621 \twocol{viper-search-wrap-around}{t}
622 \twocol{viper-case-fold-search}{nil}
623 \twocol{viper-re-search}{t}
624 \twocol{viper-re-replace}{t}
625 \twocol{viper-re-query-replace}{t}
626 \twocol{viper-auto-indent}{nil}
627 \twocol{viper-shift-width}{8}
628 \twocol{viper-tags-file-name}{"TAGS"}
629 \twocol{viper-no-multiple-ESC}{t}
630 \twocol{viper-ex-style-motion}{t}
631 \twocol{viper-always}{t}
632 \twocol{viper-custom-file-name}{"\~{}/.vip"}
633 \twocol{ex-find-file-shell}{"csh"}
634 \twocol{ex-cycle-other-window}{t}
635 \twocol{ex-cycle-through-non-buffers}{t}
636 \twocol{blink-matching-paren}{t}
637 \twocol{buffer-read-only}{{\it buffer dependent}}
640 To bind keys in Vi command state, put lines like these in your
641 \kbd{\~{}/.vip} file:
643 \beginexample
644 (define-key viper-vi-global-user-map "\\C-v" 'scroll-down)
645 (define-key viper-vi-global-user-map "\\C-cm" 'smail)
646 \endexample
649 \newcolumn
651 \title{Ex Commands in Viper}
653 In vi state, an Ex command is entered by typing:
655 \hskip 5ex
656 \kbd{:\ {\sl ex-command} RET}
658 \section{Ex Addresses}
660 \paralign to \hsize{#\tabskip=5pt plus 1 fil&#\tabskip=2pt&#\tabskip=5pt plus 1 fil&#\cr
661 \twocolkey{current line}{.}{next line with {\sl pat}}{/ {\sl pat} /}
662 \twocolkey{line {\it n}}{{\it n}}{previous line with {\sl pat}}{?\ {\sl pat} ?}
663 \twocolkey{last line}{\$}{{\it n\/} line before {\it a}}{{\it a} - {\it n}}
664 \twocolkey{next line}{+}{{\it a\/} through {\it b}}{{\it a\/} , {\it b}}
665 \twocolkey{previous line}{-}{line marked with {\it x}}{' {\it x}}
666 \twocolkey{entire buffer}{\%}{previous context}{' '}
669 Addresses can be specified in front of a command.
670 For example,
672 \hskip 5ex
673 \kbd{:.,.+10m\$}
675 moves 11 lines below current line to the end of buffer.
677 \section{Ex Commands}
679 Avoid Ex text manipulation commands except substitute.
680 There are better VI equivalents
681 for all of them. Also note that all Ex commands expand \% to
682 current file name. To include a \% in the command, escape it with a $\backslash$.
683 Similarly, \# is replaced by previous file. For Viper, this is the
684 first file in the {\sl :args} listing for that buffer. This defaults
685 to the previous file in the VI sense if you have one window.
686 Ex commands can be made to have history. See the manual for details.
688 \subsection{Ex Text Commands}
690 \endindentedkeys
692 \key{mark lines matching {\sl pat} and execute {\sl cmds} on these lines}{:g /{\sl pat}/ {\sl cmds}}
694 \key{mark lines {\it not\/} matching {\sl pat} and execute {\sl cmds} on these lines}{:v /{\sl pat}/ {\sl cmds}}
697 \key{{\bf move} specified lines after {\sl addr}}{:m {\sl addr}}
698 \key{{\bf copy} specified lines after {\sl addr}}{:co\rm\ (or \kbd{:t})\ \sl addr}
699 \key{{\bf delete} specified lines [into register {\it x\/}]}{:d {\rm [{\it x\/}]}}
700 \key{{\bf yank} specified lines [into register {\it x\/}]}{:y {\rm [{\it x\/}]}}
701 \key{{\bf put} back text [from register {\it x\/}]}{:pu {\rm [{\it x\/}]}}
703 \key{{\bf substitute} {\sl repl} for first string on line matching {\sl pat}}{:s /{\sl pat}/{\sl repl}/}
705 \key{repeat last substitution}{:\&}
706 \key{repeat previous substitute with previous search pattern as {\sl pat}}{:\~{}}
708 \subsection{Ex File and Shell Commands}
710 \key{{\bf edit} file}{:e {\sl file}}
711 \key{reedit messed up current file}{:e!}
712 \key{edit previous file}{:e\#}
713 \key{{\bf read} in a file}{:r {\sl file}}
714 \key{{\bf read} in the output of a shell command}{:r {\sl !command}}
715 \key{write out specified lines into {\sl file}}{:w {\sl file}}
716 \key{save all modified buffers, ask confirmation}{:W {\sl file}}
717 \key{save all modified buffers, no confirmation}{:WW {\sl file}}
718 \key{write out specified lines at the end of {\sl file}}{:w>> {\sl file}}
719 \key{{\bf write} to the input of a shell command}{:w {\sl !command}}
720 \key{write out and then quit}{:wq {\sl file}}
722 \key{run a sub{\bf shell} in a window}{:sh}
723 \key{execute shell command {\sl command}}{:!\ {\sl command}}
724 \key{execute previous shell command with {\it args} appended}{:!! {\sl args}}
726 \subsection{Ex Miscellaneous Commands}
728 \key{define a macro {\it x} that expands to {\sl cmd}}{:map {\it x} {\sl cmd}}
729 \key{remove macro expansion associated with {\it x}}{:unma {\it x}}
730 \key{define a macro {\it x} that expands to {\sl cmd} in insert state}{:map!\ {\it x} {\sl cmd}}
731 \key{remove macro expansion associated with {\it x} in insert state}{:unma!\ {\it x}}
733 \key{print line number}{:.=}
734 \key{print last line number}{:=}
735 \key{print {\bf version} number of Viper}{:ve}
737 \key{shift specified lines to the right}{:>}
738 \key{shift specified lines to the left}{:<}
740 \key{{\bf join} lines}{:j}
741 \key{mark specified line to register {\it x}}{:k {\it x}}
742 \key{{\bf set} a variable's value}{:se}
743 \key{find first definition of {\bf tag} {\sl tag}}{:ta {\sl tag}}
745 \key{Current directory}{:pwd}
748 \copyrightnotice
750 \bye
752 % Local variables:
753 % compile-command: "pdftex viperCard"
754 % End:
756 % arch-tag: e287b45c-4c5e-4bf9-ae28-ead4cd9f68e3