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