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