annotate man/viper.texi @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children bcdc7deadc19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 % -*-texinfo-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 %
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 \input texinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 @comment Using viper.info instead of viper in setfilename breaks DOS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @setfilename ../info/viper.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 @comment @setfilename viper.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 @iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 @finalout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 @end iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 @titlepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 @title Viper Is a Package for Emacs Rebels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 @subtitle a Vi emulator for GNU Emacs 19 and XEmacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 @subtitle June 1996, Viper Version 2.90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 @author Masahiko Sato (VIP 3.5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 @author Aamod Sane (VIP 4.4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 @author Michael Kifer (Viper)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 @page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 @vskip 0pt plus 1fill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 @end titlepage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 @unnumbered Distribution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 Copyright @copyright{} 1995, 1996 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 Permission is granted to make and distribute verbatim copies of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 this manual provided the copyright notice and this permission notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 are preserved on all copies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 @ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 Permission is granted to process this file through TeX and print the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 results, provided the printed document carries copying permission
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 notice identical to this one except for the removal of this paragraph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (this paragraph not being relevant to the printed manual).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 @end ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Permission is granted to copy and distribute modified versions of this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 manual under the conditions for verbatim copying, provided that the entire
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 resulting derived work is distributed under the terms of a permission
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 notice identical to this one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 Permission is granted to copy and distribute translations of this manual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 into another language, under the same conditions as for modified versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 @ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 @node Top, Overview,, (DIR)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 @unnumbered Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 We believe that one or more of the following statements are adequate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 descriptions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 Viper Is a Package for Emacs Rebels;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 it is a VI Plan for Emacs Rescue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 and/or a venomous VI PERil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Technically speaking, Viper is a Vi emulation package for GNU Emacs 19 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 XEmacs 19. Because of its reliance on minor mode keymaps, Viper will not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 work under Emacs 18. Viper implements most Vi and Ex commands. It gives you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 the best of both worlds: Vi keystrokes for editing combined with the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Emacs environment. Viper also fixes some common complaints with Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 commands. This manual describes Viper, concentrating on the differences
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 from Vi and new features of Viper.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 Viper, formerly known as VIP-19, was written by Michael Kifer. It is based
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 on VIP version 3.5 by Masahiko Sato and VIP version 4.4 by Aamod Sane.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Viper tries to be compatible with these packages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 Viper is intended to be usable without reading this manual --- the defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 are set to make Viper as close to Vi as possible. At startup, Viper will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 try to set the most appropriate default environment for you, based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 your familiarity with Emacs. It will also tell you the basic GNU Emacs window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 management commands to help you start immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 Although this manual explains how to customize Viper, some basic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 familiarity with Emacs Lisp would be a plus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 It is recommended that you read the Overview node. The other nodes may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 be visited as needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 Comments and bug reports are welcome.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 @code{kifer@@cs.emacs.edu} is the current address for Viper bug reports.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 Please use the Ex command @kbd{:submitReport} for this purpose.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 @end ifinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 * Overview:: Must read to get started
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 * Improvements over Vi:: New features, Improvements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 * Customization:: How to customize Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 * Commands:: Vi and Ex Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 * Key Index:: Index of Vi and Ex Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 * Function Index:: Index of Viper Functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 * Variable Index:: Index of Viper Variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 * Package Index:: Index of Packages Mentioned in this Document
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 * Concept Index:: Vi, Ex and Emacs concepts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 * Acknowledgments::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 @iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 @unnumbered Introduction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 We believe that one or more of the following statements are adequate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 descriptions:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Viper Is a Package for Emacs Rebels;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 it is a VI Plan for Emacs Rescue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 and/or a venomous VI PERil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 Technically speaking, Viper is a Vi emulation package for GNU Emacs 19 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 XEmacs 19. Because of its reliance on minor mode keymaps,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 it will not work under Emacs 18. Viper contains virtually all of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 Vi and Ex functionality and much more. It gives you the best of both
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 worlds: Vi keystrokes for editing combined with the GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 environment. Viper also fixes some common complaints with Vi commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 This manual describes Viper, concentrating on the differences from Vi and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 on the new features of Viper.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 Viper, formerly known as VIP-19, was written by Michael Kifer. It is based
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 on VIP version 3.5 by Masahiko Sato and VIP version 4.4 by Aamod Sane.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 Viper tries to be compatible with these packages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 Viper is intended to be usable without reading this manual --- the defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 are set to make Viper as close to Vi as possible. At startup, Viper will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 attempt to set the most appropriate default environment for you, based on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 your familiarity with Emacs. It will also tell you the basic GNU Emacs window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 management commands to help you start immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 Although this manual explains how to customize Viper, some basic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 familiarity with Emacs Lisp would be a plus.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 It is recommended that you read the chapter Overview. The other chapters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 will be useful for customization and advanced usage.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 You should also learn to use the Info on-line hypertext manual system that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 comes with Emacs. This manual can be read as an Info file. Try the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 @kbd{ESC x info} with vanilla Emacs sometime.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 Comments and bug reports are welcome.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 @code{kifer@@cs.sunysb.edu} is the current address for Viper bug reports.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 Please use the Ex command @kbd{:submitReport} for this purpose.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 @end iftex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 @node Overview,Improvements over Vi,Top,Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 @chapter Overview of Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 Viper is a Vi emulation on top of Emacs. At the same time, Viper provides a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 virtually unrestricted access to Emacs facilities. Perfect compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 with Vi is possible but not desirable. This chapter tells you about the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 Emacs ideas that you should know about, how to use Viper within Emacs and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 some incompatibilities.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 Viper was formerly known as VIP-19, which was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 a descendant of VIP 3.5 by Masahiko Sato and VIP 4.4 by Aamod Sane.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 * Emacs Preliminaries:: Basic concepts in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 * Loading Viper:: Loading and Preliminary Configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 * States in Viper:: Viper has four states orthogonal to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 modes in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 * The Minibuffer:: Command line in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 * Multiple Files in Viper:: True multiple file handling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 * Unimplemented Features:: That are unlikely to be implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 @node Emacs Preliminaries, Loading Viper, Overview, Overview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 @section Emacs Preliminaries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 @cindex buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 @cindex point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 @cindex mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 @cindex text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 @cindex looking at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 @cindex end (of buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 @cindex end (of line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 @cindex region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 Emacs can edit several files at once. A file in Emacs is placed in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 @dfn{buffer} that usually has the same name as the file. Buffers are also used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 for other purposes, such as shell interfaces, directory editing, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 @xref{Dired,,Directory Editor,emacs,The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 Gnu Emacs Manual}, for an example.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 A buffer has a distinguished position called the @dfn{point}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 A @dfn{point} is always between 2 characters, and is @dfn{looking at}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 the right hand character. The cursor is positioned on the right hand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 character. Thus, when the @dfn{point} is looking at the end-of-line,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 the cursor is on the end-of-line character, i.e. beyond the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 character on the line. This is the default Emacs behavior.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 The default settings of Viper try to mimic the behavior of Vi,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 preventing the cursor from going beyond the last character on the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 By using Emacs commands directly (such as those bound to arrow keys), it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 to get the cursor beyond the end-of-line. However, this won't (or shouldn't)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 happen if you restrict yourself to standard Vi keys, unless you modify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 default editing style. @xref{Customization}.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 In addition to the @dfn{point}, there is another distinguished buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 position called the @dfn{mark}. @xref{Mark,,Mark,emacs,The GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 manual}, for more info on the mark. The text between the @dfn{point} and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 @dfn{mark} is called the @dfn{region} of the buffer. For the Viper user,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 this simply means that in addition to the Vi textmarkers a--z, there is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 another marker called @dfn{mark}. This is similar to the unnamed Vi marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 used by the jump commands (`` and ''), which move the cursor to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 position of the last absolute jump.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 Viper provides access to the region in most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 text manipulation commands as @kbd{r} and @kbd{R} suffix to commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 that operate on text regions, e.g., @kbd{dr} to delete region, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 @xref{Basics}, for more info.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 @cindex window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 @cindex mode line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 @cindex buffer information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 @cindex Minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 @cindex command line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 @cindex buffer (modified)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 Emacs divides the screen into tiled @dfn{windows}. You can see the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 contents of a buffer through the window associated with the buffer. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 cursor of the screen is positioned on the character after @dfn{point}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 Every window has a @dfn{mode line} that displays information about the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 You can change the format of the mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 line, but normally if you see @samp{**} at the beginning of a mode line it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 means that the buffer is @dfn{modified}. If you write out the contents of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 a buffer to a file, then the buffer will become not modified. Also if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 you see @samp{%%} at the beginning of the mode line, it means that the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 associated with the buffer is write protected. The mode line will also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 show the buffer name and current major and minor modes (see below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 A special buffer called @dfn{Minibuffer} is displayed as the last line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 in a Minibuffer window. The Minibuffer window is used for command input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 output. Viper uses Minibuffer window for @kbd{/} and @kbd{:}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 commands.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 @cindex mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 @cindex keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 @cindex local keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 @cindex global keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 @cindex major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 @cindex minor mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 An Emacs buffer can have a @dfn{major mode} that customizes Emacs for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 editing text of a particular sort by changing the functionality of the keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 Keys are defined using a @dfn{keymap} that records the bindings between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 keystrokes and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 functions. The @dfn{global keymap} is common to all the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 buffers. Additionally, each buffer has its @dfn{local keymap} that determines the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 @dfn{mode} of the buffer. If a function is bound to some key in the local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 keymap then that function will be executed when you type the key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 If no function is bound to a key in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 local map, however, the function bound to the key in the global map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 will be executed. @xref{Major Modes,Major Modes,Major Modes,emacs,The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 GNU Emacs Manual}, for more information.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 A buffer can also have a @dfn{minor mode}. Minor modes are options that you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 can use or not. A buffer in @code{text-mode} can have @code{auto-fill-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 as minor mode, which can be turned off or on at any time. In Emacs 19, a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 minor mode may have it own keymap, which overrides the local keymap when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 the minor mode is turned on. For more information, @pxref{Minor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 Modes,Minor Modes,Minor Modes,emacs,The GNU Emacs Manual} @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 @cindex Viper as minor mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 @cindex Control keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 @cindex Meta key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 Viper is implemented as a collection of minor modes. Different minor modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 are involved when Viper emulates Vi command mode, Vi insert mode, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 You can also turn Viper on and off at any time while in Vi command mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 @xref{States in Viper}, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 more information.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 Emacs uses Control and Meta modifiers. These are denoted as C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 and M, e.g. @kbd{^Z} as @kbd{C-z} and @kbd{Meta-x} as @kbd{M-x}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 The Meta key is usually located on each side of the Space bar; it is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 in a manner similar to the Control key, e.g., @kbd{M-x} means typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 @kbd{x} while holding the Meta key down.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 For keyboards that do not have a Meta key, @key{ESC} is used as Meta.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 Thus @kbd{M-x} is typed as @kbd{ESC x}. Viper uses @key{ESC} to switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 from Insert state to Vi state. Therefore Viper defines @kbd{_} as its Meta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 key in Vi state. @xref{Vi State}, for more info.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 Emacs is structured as a lisp interpreter around a C core. Emacs keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 cause lisp functions to be called. It is possible to call these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 functions directly, by typing @kbd{M-x function-name}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 @node Loading Viper, States in Viper, Emacs Preliminaries, Overview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 @section Loading Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 First, make sure that all six Viper files @file{viper*.el} are somewhere on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 Emacs @dfn{load path}. The load path is a list of directories where Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 looks for its Lisp code; it is similar to Unix environment variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 @var{PATH}. The load path is determined by the Lisp variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 @code{load-path}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 Type @code{C-h v load-path RET} to check the current load path of your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 Emacs. (Here and later, @kbd{RET} stands for carriage return.) If the files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 @file{viper*.el} are not in any directory on the load path, you should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 create your own directory and put it on the load path; then put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 @file{viper*.el} in that directory. To put a new directory, say
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 @file{~/emacslib}, on your load path, add the following line at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 beginning of your @file{~/.emacs} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (setq load-path (cons "~/emacslib" load-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 It is recommended that you compile @file{viper.el} by running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 make all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 in the directory where Viper was unpacked. The best way to ensure that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 Viper is installed properly is to run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 make install
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 in the directory where Viper was unpacked. See README in the Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 distribution for the details on which modifications to the make file may be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 necessary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 Once Viper is settled on the load path,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 the most common way to load it automatically is to include the line:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (require 'viper)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 in your @file{~/.emacs} file. The @file{.emacs} file is placed in your home
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 directory and it will be executed every time you invoke Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 Viper also uses the file @file{~/.vip} for Viper-specific customization.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 If you wish
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 to be in Vi command state whenever this is appropriate, you can include the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 line in your @file{.vip}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (setq vip-always t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (@xref{Vi State}, for the explanation of Vi mode.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 Once invoked, Viper will arrange to bring up Emacs buffers in Vi state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 whenever this makes sense.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 @xref{Packages that Change Keymaps}, to find out when forcing Vi command state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 on a buffer may be counter-productive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 Even if your @file{.emacs} and @file{.vip} files do not contain any of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 above lines, you can still load Viper and enter Vi state by typing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 following from within Emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 M-x load-library RET viper RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 M-x viper-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 Ask your local Emacs administrator if this fails to work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 When Emacs first comes up, if you have not specified a file on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 command line, it will show the @samp{*scratch*} buffer, in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 @samp{Lisp Interaction} mode. After you invoke Viper, you can start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 editing files by using @kbd{:e}, @kbd{:vi}, or @kbd{v} commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (@xref{File and Buffer Handling}, for more information on @kbd{v} and other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 new commands that, in many cases, are more convenient than @kbd{:e},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 @kbd{:vi}, and similar old-style Vi commands.)@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 @node States in Viper, The Minibuffer, Loading Viper,Overview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 @section States in Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 @kindex @kbd{C-z}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 @kindex @kbd{C-z}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 @kindex @kbd{ESC}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 @kindex @kbd{i}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 @cindex Emacs state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 @cindex Vi state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 @cindex Insert state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 @cindex Replace state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 @cindex Ex commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 Viper has four states, Emacs, Vi, Insert, and Replace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 @table @samp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 @item Emacs state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 This is the mode plain vanilla Emacs is normally in. After you have loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 Viper, @kbd{C-z} will normally take you to Vi command state. Another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 @kbd{C-z} will take you back to Emacs state. This toggle key can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 changed, @pxref{Customization} You can also type @kbd{M-x viper-mode} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 change to Vi state.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 For users who chose to set their user level to 1 at Viper setup time,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 switching to Emacs state is deliberately made harder in order to not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 confuse the novice user. In this case, @kbd{C-z} will either iconify Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (if Emacs runs as an application under X Windows) or it will stop Emacs (if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 Emacs runs on a dumb terminal or in an Xterm window).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 @item Vi state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 This is the Vi command mode. Any of the Vi commands, such as @kbd{i, o, a},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 @dots{}, will take you to Insert state. All Vi commands may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 be used in this mode. Most Ex commands can also be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 For a full list of Ex commands supported by Viper, type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 @kbd{:} and then @kbd{TAB}. To get help on any issue, including the Ex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 commands, type @kbd{:help}. This will invoke Viper Info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (if it is installed). Then typing @kbd{i} will prompt you for a topic to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 search in the index. Note, to search for Ex commands in the index, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 should start them with a ``@kbd{:}'', e.g., @kbd{:WW}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 @item Insert state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 Insert state is the Vi insertion mode. @kbd{ESC} will take you back to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 Vi state. Insert state editing can be done, including auto-indentation. By
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 default, Viper disables Emacs keybindings in Insert state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 @item Replace state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 Commands like @kbd{cw} invoke the Replace state. When you cross the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 boundary of a replacement region (usually designated via a @samp{$} sign),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 it will automatically change to Insert state. You do not have to worry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 about it. The key bindings remain practically the same as in Insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 state. If you type ESC, Viper will switch to Vi command mode, terminating the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 replacement state. @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 @cindex mode line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 The modes are indicated on the @dfn{mode line} as <E>, <I>, <V>, and <R>,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 so that the multiple modes do not confuse you. Most of your editing can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 done in Vi and Insert states. Viper will try to make all new buffers be in Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 state, but sometimes they may come up in Emacs state. @kbd{C-z}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 will take you to Vi state in such a case. In some major modes, like Dired,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 Info, Gnus, etc., you should not switch to Vi state (and Viper will not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 attempt to do so) because these modes are not intended for text editing and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 many of the Vi keys have special meaning there. If you plan to read news,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 browse directories, read mail, etc., from Emacs (which you should start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 doing soon!), you should learn about the meaning of the various keys in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 those special modes (typing @kbd{C-h m} in a buffer provides
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 help with key bindings for the major mode of that buffer).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 If you switch to Vi in Dired or similar modes---no harm is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 done. It is just that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 the special keybindings provided by those modes will be temporarily
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 overshadowed by Viper's bindings. Switching back to Viper's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 Emacs state will revive the environment provided by the current major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 States in Viper are orthogonal to Emacs major modes, such as C mode or Dired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 mode. You can turn Viper on and off for any Emacs state. When Viper is turned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 on, Vi state can be used to move around. In Insert state, the bindings for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 these modes can be accessed. For beginners (users at Viper levels 1 and 2),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 these bindings are suppressed in Insert state, so that new users are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 confused by the Emacs states. Note that unless you allow Emacs bindings in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 Insert state, you cannot do many interesting things, like language
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 sensitive editing. For the novice user (at Viper level 1), all major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 bindings are turned off in Vi state as well. This includes the bindings for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 key sequences that start with @kbd{C-c}, which practically means that all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 major mode bindings are supported. @xref{Customization}, to find out how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 to allow Emacs keys in Insert state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 * Emacs State:: This is the state you should learn more about when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 you get up to speed with Viper.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 * Vi State:: Vi commands are executed in this state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 * Insert State:: You can enter text, and also can do sophisticated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 editing if you know enough Emacs commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 * Replace State:: Like Insert mode, but it is invoked via the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 replacement commands, such as cw, C, R, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 @node Emacs State, Vi State, States in Viper, States in Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 @subsection Emacs State
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 @kindex @kbd{C-z}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 @cindex Emacs state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 You will be in this mode only by accident (hopefully). This is the state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 Emacs is normally in (imagine!!). Now leave it as soon as possible by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 typing @kbd{C-z}. The you will be in Vi state (sigh of relief) :-).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 Emacs state is actually a Viperism to denote all the major and minor modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (@xref{Emacs Preliminaries}) other than Viper that Emacs can be in. Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 can have several modes, such as C mode for editing C programs, LaTeX mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 for editing LaTeX documents, Dired for directory editing, etc. These are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 major modes, each with a different set of key-bindings. Viper states are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 orthogonal to these Emacs major modes. The presence of these language
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 sensitive and other modes is a major win over Vi. @xref{Improvements over
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 Vi}, for more.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 The bindings for these modes can be made available in the Viper Insert state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 as well as in Emacs state. Unless you specify your user level as 1 (a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 novice), all major mode key sequences that start with @kbd{C-x} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 @kbd{C-c} are also available in Vi state. This is important because major
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 modes designed for editing files, such as cc-mode or latex-mode, use key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 sequences that begin with @kbd{C-x} and @kbd{C-c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 There is also a key that lets you temporarily escape to Vi command state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 from Emacs state: typing @kbd{M-C-z} (or @kbd{ESC C-z}) will let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 you execute a single Vi command while staying in Viper's Emacs state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 At present, this works only for 1-character Vi commands (and for some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 complex commands).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 @node Vi State, Insert State, Emacs State, States in Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 @subsection Vi State
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 @cindex Vi state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 This is the Vi command mode. When Viper is in Vi state, you will see the sign
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 <V> in the mode line. Most keys will work as in Vi. The notable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 exceptions are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 @item C-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 @kindex @kbd{C-x}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 @kbd{C-x} is used to invoke Emacs commands, mainly those that do window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 management. @kbd{C-x 2} will split a window, @kbd{C-x 0} will close a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 window. @kbd{C-x 1} will close all other windows. @kbd{C-xb} is used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 switch buffers in a window, and @kbd{C-xo} to move through windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 These are about the only necessary keystrokes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 For the rest, see the GNU Emacs Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 @item C-c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 @kindex @kbd{C-c}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 For user levels 2 and higher, this key serves as a prefix key for the key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 sequences used by various major modes. For users at Viper level 1, @kbd{C-c}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 simply beeps.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 @item C-g and C-]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 @kindex @kbd{C-g}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 @kindex @kbd{C-]}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 These are the Emacs @samp{quit} keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 There will be cases where you will have to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 use @kbd{C-g} to quit. Similarly, @kbd{C-]} is used to exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 @samp{Recursive Edits} in Emacs for which there is no comparable Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 functionality and no key-binding. Recursive edits are indicated by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 @samp{[]} brackets framing the modes on the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 @xref{Recursive Edit,Recursive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 Edit,Recursive Edit,emacs,The GNU Emacs Manual}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 At user level 1, @kbd{C-g} is bound to @code{vip-info-on-file}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 function instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 @item Underscore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 @kindex @kbd{_}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 @cindex Meta key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 Viper uses @kbd{ESC} as a switch between Insert and Vi states. Emacs uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 @kbd{ESC} for Meta. We need a Meta key to call the Meta key functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 such as @kbd{M-x function name}. The underscore key, @kbd{_}, was chosen,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 since it is the only reasonable, free Vi key left. Thus, in Vi state, to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 get @kbd{M-x}, you should type @kbd{_x} (if the keyboard has no Meta key).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 It is possible to use @kbd{ESC} as Meta, but then you cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 press @kbd{ESC} multiple times in Vi state. @xref{Customization}, to find
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 out how to rebind ESC to be Meta.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 Other differences are mostly improvements. The ones you should know
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 about are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 @table @samp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 @item Undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 @kindex @kbd{u}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 @kbd{u} will undo. Undo can be repeated by the @kbd{.} key. Undo itself
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 can be undone. Another @kbd{u} will change the direction. The presence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 of repeatable undo means that @kbd{U}, undoing lines, is not very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 important. Therefore, @kbd{U} also calls @code{vip-undo}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 @cindex multiple undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 @cindex undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 @item Counts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 Most commands, @kbd{~}, @kbd{[[}, @kbd{p}, @kbd{/}, @dots{}, etc., take counts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 @comment ]] Just to balance parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 @item Regexps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 Viper uses Emacs Regular Expressions for searches. These are a superset of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 Vi regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 expressions, excepting the change-of-case escapes @samp{\u}, @samp{\L},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 @dots{}, etc. @xref{Regular Expressions,,Regular Expressions,emacs,The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 GNU Emacs Manual}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 Files specified to @kbd{:e} use @code{csh} regular expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (globbing, wildcards, what have you).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 However, the function @code{vip-toggle-search-style}, bound to @kbd{C-c /},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 lets the user switch from search with regular expressions to plain vanilla
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 search and vice versa. It also lets one switch from case-sensitive search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 to case-insensitive and back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 @xref{Viper Specials}, for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 @cindex regular expressions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 @cindex vanilla search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 @cindex case-sensitive search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 @cindex case-insensitive search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 @kindex @kbd{C-c /}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 @item Ex commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 @cindex Ex commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 The current working directory of a buffer is automatically inserted in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 minibuffer if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 type @kbd{:e} then space.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 Absolute filenames are required less often in Viper.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 For path names,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 Emacs uses a convention that is slightly different from that of Unix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 It is designed to minimize the need for deleting path names that Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 provides in its prompts. (This is usually convenient, but occasionally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 the prompt may suggest a wrong path name for you.) If you see a prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 @kbd{/usr/foo/} and you wish to edit the file @kbd{~/.vip}, you don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 have to erase the prompt. Instead, simply continue typing what you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 need. Emacs will interpret @kbd{/usr/foo/~/.vip} correctly. Similarly,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 if the prompt is @kbd{~/foo/} and you need to get to @kbd{/bar/file}, keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 typing. Emacs interprets @kbd{~/foo//bar/} as @kbd{/bar/file}, since when it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 sees @samp{//}, it understands that @kbd{~/foo/} is to be discarded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 The command @kbd{:cd} will change the default directory for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 current buffer. The command @kbd{:e} will interpret the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 filename argument in @code{csh}. @xref{Customization}, if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 want to change the default shell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 The command @kbd{:next} takes counts from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 @kbd{:args}, so that @kbd{:rew} is obsolete. Also, @kbd{:args} will show only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 the invisible files (i.e., those that are not currently seen in Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 windows).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 When applicable, Ex commands support file completion and history. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 means that by typing a partial file name and then @kbd{TAB}, Emacs will try
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 to complete the name or it will offer a menu of possible completions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 This works similarly to Tcsh and extends the behavior of Csh. While Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 is waiting for a file name, you can type @kbd{M-p} to get the previous file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 name you typed. Repeatedly typing @kbd{M-p} and @kbd{M-n} will let you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 browse through the file history.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 Like file names, partially typed Ex commands can be completed by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 @kbd{TAB}, and Viper keeps the history of Ex commands. After typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 @kbd{:}, you can browse through the previously entered Ex commands by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 typing @kbd{M-p} and @kbd{M-n}. Viper tries to rationalize when it puts Ex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 commands on the history list. For instance, if you typed @kbd{:w! foo},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 only @kbd{:w!} will be placed on the history list. This is because the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 last history element is the default that can be invoked simply by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 @kbd{: RET}. If @kbd{:w! foo} were placed on the list, it would be all to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 easy to override valuable data in another file. Reconstructing the full
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 command, @kbd{:w! foo}, from the history is still not that hard, since Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 has a separate history for file names. By typing @kbd{: M-p}, you will get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 @kbd{:w!} in the Minibuffer. Then, repeated @kbd{M-p} will get you through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 the file history, inserting one file name after another.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 In contrast to @kbd{:w! foo}, if the command were @kbd{:r foo}, the entire
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 command will appear in the history list. This is because having @kbd{:r}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 alone as a default is meaningless, since this command requires a file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 As Vi, Viper's destructive commands can be re-executed by typing `@kbd{.}'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 However, in addition, Viper keeps track of the history of such commands. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 history can be perused by typing @kbd{C-c M-p} and @kbd{C-c M-n}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 Having found the appropriate command, it can be then executed by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 `@kbd{.}'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 @xref{Improvements over Vi}, for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 @node Insert State, Replace State, Vi State, States in Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 @subsection Insert State
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 @cindex Insert state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 To avoid confusing the beginner (at Viper level 1 and 2), Viper makes only the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 standard Vi keys available in Insert state. The implication is that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 Emacs major modes cannot be used Insert state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 It is strongly recommended that as soon as you are comfortable, make the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 Emacs state bindings visible (by changing your user level to 3 or higher).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 @xref{Customization},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 to see how to do this.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 Once this is done, it is possible to do quite a bit of editing in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 Insert state. For instance, Emacs has a @dfn{yank} command, @kbd{C-y},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 which is similar to Vi's @kbd{p}. However, unlike @kbd{p}, @kbd{C-y} can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 used in Insert state of Viper. Emacs also has a kill ring where it keeps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 pieces of text you deleted while editing buffers. The command @kbd{M-y} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 used to delete the text previously put back by Emacs' @kbd{C-y} or by Vi's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 @kbd{p} command and reinsert text that was placed on the kill-ring earlier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 This works both in Vi and Insert states.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 In Vi state, @kbd{M-y} is a much better alternative to the usual Vi's way
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 of recovering the 10 previously deleted chunks of text. In Insert state,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 you can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 use this as follows. Suppose you deleted a piece of text and now you need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 to re-insert it while editing in Insert mode. The key @kbd{C-y} will put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 back the most recently deleted chunk. If this is not what you want, type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 @kbd{M-y} repeatedly and, hopefully, you will find the chunk you want.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 Finally, in Insert and Replace states, Viper provides the history of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 pieces of text inserted in previous insert or replace commands. These
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 strings of text can be recovered by repeatedly typing @kbd{C-c M-p} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 @kbd{C-c M-n} while in Insert or Replace state. (This feature is disabled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 in the minibuffer: the above keys are usually bound to other histories,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 which are more appropriate in the minibuffer.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 @cindex Meta key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 You can call Meta functions from Insert state. The Vi-to-Emacs toggle key,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 normally @kbd{C-z}, is bound to Meta in Insert state. Thus @kbd{M-x} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 typed as @kbd{C-zx}. The key @kbd{_} will now insert itself---it is not a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 Meta key in Insert state. (It is well understood that switching Meta keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 around is inconvenient. However, there seems to be no way around this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 problem, short of changing Vi ESC key to something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 else. @xref{Customization}, for the information on @code{vip-ESC-key}, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 can be used to free up @kbd{ESC} and designate some other key to do escape
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 from Insert state to Vi state.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 Other Emacs commands that are useful in Insert state are @kbd{C-e}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 and @kbd{C-a}, which move the cursor to the end and the beginning of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 current line, respectively. You can also use @kbd{M-f} and @kbd{M-b},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 which move the cursor forward (or backward) one word.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 If your display has a Meta key, these functions are invoked by holding the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 Meta key and then typing @kbd{f} and @kbd{b}, respectively. On displays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 without the Meta key, these functions are invoked by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 @kbd{C-z f} and @kbd{C-z b} (@kbd{C-z} simulates the Meta key in Insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 state, as explained above).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 When Viper is in Insert state, you will see <I> in the mode line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 @node Replace State,, Insert State, States in Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 @subsection Replace State
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 @cindex Replace state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 This state is entered through Vi replacement commands, such as @kbd{C},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 @kbd{cw}, etc., or by typing @kbd{R}. In Replace state, Viper puts <R> in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 mode line to let you know which state is in effect. If Replace state is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 entered through @kbd{R}, Viper stays in that state until the user hits ESC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 If this state is entered via the other replacement commands, then Replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 state is in effect until you hit @kbd{ESC} or until you cross the rightmost
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 boundary of the replacement region. In the latter case, Viper changes its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 state from Replace to Insert (which you will notice by the change in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 mode line).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 Since Viper runs under Emacs, it is possible to switch between buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 while in Replace state. You can also move the cursor using the arrow keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (even on dumb terminals!) and the mouse. Because of this freedom (which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 unattainable in regular Vi), it is possible to take the cursor outside the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 replacement region. (This may be necessary for several reasons, including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 the need to enable text selection and region-setting with the mouse.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 The issue then arises as to what to do when the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 hits the ESC key. In Vi, this would cause the text between cursor and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 the end of the replacement region to be deleted. But what if, as is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 possible in Viper, the cursor is not inside the replacement region?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 To solve the problem, Viper keeps track of the last cursor position while it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 was still inside the replacement region. So, in the above situation, Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 would delete text between this position and the end of the replacement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 @node The Minibuffer,Multiple Files in Viper, States in Viper, Overview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 @section The Minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 @cindex Minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 The Minibuffer is where commands are entered in. Editing can be done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 by commands from Insert state, namely:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 @item C-h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 Backspace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 @item C-w
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 Delete Word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 @item C-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 Erase line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 @item C-v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 Quote the following character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 @item RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 Execute command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 @item C-g and C-]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 Emacs quit and abort keys. These may be necessary. @xref{Vi State}, for an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 explanation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 @item M-p and M-n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 These keys are bound to functions that peruse minibuffer history. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 precise history to be perused depends on the context. It may be the history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 of search strings, Ex commands, file names, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 Most of the Emacs keys are functional in the Minibuffer. While in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 Minibuffer, Viper tries to make editing resemble Vi's behavior when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 latter is waiting for the user to type an Ex command. In particular, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 can use the regular Vi commands to edit the Minibuffer. You can switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 between the Vi state and Insert state at will, and even use the replace mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 Initially, the Minibuffer comes up in Insert state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 Some users prefer plain Emacs bindings in the Minibuffer. To this end, set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 @code{vip-vi-style-in-minibuffer} to @code{nil} in @file{.vip}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 @xref{Customization}, to learn how to do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 When the Minibuffer changes Viper states, you will notice that the appearance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 of the text there changes as well. This is useful because the Minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 has no mode line to tell which Vi state it is in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 The appearance of the text in the Minibuffer can be changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 @xref{Viper Specials}, for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 @node Multiple Files in Viper,Unimplemented Features,The Minibuffer,Overview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 @section Multiple Files in Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 @cindex multiple files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 @cindex managing multiple files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 Viper can edit multiple files. This means, for example that you never need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 to suffer through @code{No write since last change} errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 Some Viper elements are common over all the files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 @table @samp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 @item Textmarkers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 @cindex markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 @cindex textmarkers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 Textmarkers remember @emph{files and positions}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 If you set marker @samp{a} in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 file @file{foo}, start editing file @file{bar} and type @kbd{'a}, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 @emph{YOU WILL SWITCH TO FILE @file{foo}}. You can see the contents of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 textmarker using the Viper command @kbd{[<a-z>} where <a-z> are the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 textmarkers, e.g., @kbd{[a} to view marker @samp{a} .@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 @item Repeated Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 Command repetitions are common over files. Typing @kbd{!!} will repeat the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 last @kbd{!} command whichever file it was issued from.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 Typing @kbd{.} will repeat the last command from any file, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 searches will repeat the last search. Ex commands can be repeated by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 @kbd{:RET}.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 Note: in some rare cases, that @kbd{:RET} may do something dangerous.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 However, usually its effect can be undone by typing @kbd{u}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 @item Registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 @cindex registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 Registers are common to files. Also, text yanked with @kbd{y} can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 put back (@kbd{p}) into any file. The Viper command @kbd{]<a-z>}, where <a-z> are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 the registers, can be used to look at the contents of a register, e.g.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 type @kbd{]a} to view register @samp{a}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 There is one difference in text deletion that you should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 aware of. This difference comes from Emacs and was adopted in Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 because we find it very useful. In Vi, if you delete a line, say, and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 another line, these two deletions are separated and are put back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 separately if you use the @samp{p} command. In Emacs (and Viper), successive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 series of deletions that are @emph{not interrupted} by other commands are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 lumped together, so the deleted text gets accumulated and can be put back
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 as one chunk. If you want to break a sequence of deletions so that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 newly deleted text could be put back separately from the previously deleted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 text, you should perform a non-deleting action, e.g., move the cursor one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 character in any direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 @item Absolute Filenames
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 @cindex absolute paths
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 The current directory name for a file is automatically prepended to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 file name in any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 @kbd{:e}, @kbd{:r}, @kbd{:w}, etc., command (in Emacs, each buffer has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 current directory).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 This directory is inserted in the Minibuffer once you type space after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 @kbd{:e, r}, etc. Viper also supports completion of file names and Ex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 commands (@kbd{TAB}), and it keeps track of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 command and file history (@kbd{M-p}, @kbd{M-n}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 Absolute filenames are required less
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 often in Viper.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 You should be aware that Emacs interprets @kbd{/foo/bar//bla} as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 @kbd{/bla} and @kbd{/foo/~/bar} as @kbd{~/bar}. This is designed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 minimize the need for erasing path names that Emacs suggests in its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 prompts, if a suggested path name is not what you wanted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 The command @kbd{:cd} will change the default directory for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 current Emacs buffer. The Ex command @kbd{:e} will interpret the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 filename argument in @samp{csh}, by default. @xref{Customization}, if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 want to change this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 Currently undisplayed files can be listed using the @kbd{:ar} command. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 command @kbd{:n} can be given counts from the @kbd{:ar} list to switch to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 other files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 @node Unimplemented Features,,Multiple Files in Viper,Overview
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 @section Unimplemented Features
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 Unimplemented features include:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 @kbd{:ab} and @kbd{:una} are not implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 Both @kbd{:map} and @kbd{:ab} are considered obsolete, since Emacs has much
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 more powerful facilities for defining keyboard macros and abbreviations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 @kbd{:set option?} is not implemented. The current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 @kbd{:set} can also be used to set Emacs variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 @kbd{:se list} requires modification of the display code for Emacs, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 it is not implemented.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 A useful alternative is @code{cat -t -e file}. Unfortunately, it cannot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 be used directly inside Emacs, since Emacs will obdurately change @samp{^I}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 back to normal tabs.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 @node Improvements over Vi, Customization, Overview, Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 @chapter Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 Some common problems with Vi and Ex have been solved in Viper. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 includes better implementation of existing commands, new commands, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 the facilities provided by Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 * Basics:: Basic Viper differences, Multi-file effects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 * Undo and Backups:: Multiple undo, auto-save, backups and changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 * History:: History for Ex and Vi commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 * Macros and Registers:: Keyboard Macros (extended ".") @@reg execution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 * Completion:: Filename and Command Completion for Ex.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 * Improved Search:: Incremental Search and Buffer Content Search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 * Abbreviation Facilities:: Normal Abbrevs, Templates, and Dynamic Abbrevs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 * Movement and Markers:: Screen Editor movements, viewing textmarkers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 * New Commands:: Commands that do not exist in Vi.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 * Useful Packages:: A Sampling of some Emacs packages, and things
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 you should know about.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 @node Basics, Undo and Backups, Improvements over Vi, Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 @section Basics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 The Vi command set is based on the idea of combining motion commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 with other commands. The motion command is used as a text region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 specifier for other commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 We classify motion commands into @dfn{point commands} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 @dfn{line commands}.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 @cindex point commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 The point commands are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 @quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 @kbd{h}, @kbd{l}, @kbd{0}, @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 @kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 @kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}, @kbd{^}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 @end quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 @cindex line commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 The line commands are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 @quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 @kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 @kbd{@}}, @kbd{G}, @kbd{'}, @kbd{[[}, @kbd{]]}, @kbd{[]}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 @end quotation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 @cindex region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 @cindex region specification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 @cindex expanding (region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 @cindex describing regions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 @cindex movement commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 If a point command is given as an argument to a modifying command, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 region determined by the point command will be affected by the modifying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 command. On the other hand, if a line command is given as an argument to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 modifying command, the region determined by the line command will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 enlarged so that it will become the smallest region properly containing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 region and consisting of whole lines (we call this process @dfn{expanding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 the region}), and then the enlarged region will be affected by the modifying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 Text Deletion Commands (@xref{Deleting Text}), Change commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (@xref{Changing Text}), even Shell Commands (@xref{Shell Commands})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 use these commands to describe a region of text to operate on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 Thus, type @kbd{dw} to delete a word, @kbd{>@}} to shift a paragraph, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 @kbd{!'afmt} to format a region from @samp{point} to textmarker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 @samp{a}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 @cindex r and R region specifiers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 Viper adds the region specifiers @samp{r} and @samp{R}. Emacs has a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 special marker called @dfn{mark}. The text-area between the current cursor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 position @dfn{point} and the @dfn{mark} is called the @dfn{region}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 @samp{r} specifies the raw region and @samp{R} is the expanded region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (i.e., the minimal contiguous chunk of full lines that contains the raw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 region).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 @kbd{dr} will now delete the region, @kbd{>r} will shift it, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 @kbd{r,R} are not motion commands, however. The special mark is set by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 @kbd{m.} and other commands. @xref{Marking}, for more info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 Viper also adds counts to most commands for which it would make sense.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 In the Overview chapter, some Multiple File issues were discussed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (@xref{Multiple Files in Viper}). In addition to the files, Emacs has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 buffers. These can be seen in the @kbd{:args} list and switched using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 @kbd{:next} if you type @kbd{:set ex-cycle-through-non-files t}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 specify @code{(setq ex-cycle-through-non-files t)} in your @file{.vip}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 file. @xref{Customization}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 @node Undo and Backups, History, Basics, Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 @section Undo and Backups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 @cindex undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 Viper provides multiple undo. The number of undo's and the size is limited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 by the machine. The Viper command @kbd{u} does an undo. Undo can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 repeated by typing @kbd{.} (a period). Another @kbd{u} will undo the undo,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 and further
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 @kbd{.} will repeat it. Typing @kbd{u} does the first undo, and changes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 @cindex backup files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 @cindex auto save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 Since the undo size is limited, Viper can create backup files and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 auto-save files. It will normally do this automatically. It is possible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 to have numbered backups, etc. For details, @pxref{Backup,,Backup and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 Auto-Save,emacs,The GNU Emacs Manual} @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 @comment [ balance parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 @cindex viewing registers and markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 @cindex registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 @cindex markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 @cindex textmarkers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 The results of the 9 previous changes are available in the 9 numeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 registers, as in Vi. The extra goody is the ability to @emph{view} these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 registers, in addition to being able to access them through @kbd{p} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 @kbd{M-y} (@xref{Insert State}, for details.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 The Viper command @kbd{] register} will display the contents of any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 register, numeric or alphabetical. The related command @kbd{[ textmarker}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 will show the text around the textmarker. @samp{register} and @samp{textmarker}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 can be any letters from a through z.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 @comment ] balance parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 @node History, Macros and Registers, Undo and Backups,Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 @section History
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 @cindex history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 @cindex Minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 History is provided for Ex commands, Vi searches, file names, pieces of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 text inserted in earlier commands that use Insert or Replace state, and for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 destructive commands in Vi state. These are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 useful for fixing those small typos that screw up searches and @kbd{:s},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 and for eliminating routine associated with repeated typing of file names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 or pieces of text that need to be inserted frequently.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 At the @kbd{:} or @kbd{/} prompts in the Minibuffer, you can do the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 @item M-p and M-n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 To move to previous and next history items. This causes the history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 items to appear on the command line, where you can edit them, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 simply type Return to execute.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 @item M-r and M-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 To search backward and forward through the history.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 @item RET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 Type RET to accept a default (which is displayed in the prompt).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 The history of insertions can be perused by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 typing @kbd{C-c M-p} and @kbd{C-c M-n} while in Insert or Replace state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 The history of destructive Vi commands can be perused via the same keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 when Viper is in Vi state. @xref{Viper Specials}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 All Ex commands have a file history. For instance, typing @kbd{:e}, space
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 and then @kbd{M-p} will bring up the name of the previously typed file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 name. Repeatedly typing @kbd{M-p}, @kbd{M-n}, etc., will let you browse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 through the file history.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 Similarly, commands that have to do with switching buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 have a buffer history, and commands that expect strings or regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 expressions keep a history on those items.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 @node Macros and Registers,Completion,History,Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 @section Macros and Registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 @cindex keyboard macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 @cindex macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 @cindex registers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 @cindex register execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 Viper facilitates the use of Emacs-style keyboard macros. @kbd{@@#} will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 start a macro definition. As you type, the commands will be executed, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 remembered (This is called ``learn mode'' in some editors.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 @kbd{@@register} will complete the macro, putting it into @samp{register},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 where @samp{register} is any character from @samp{a} through @samp{z}. Then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 you can execute this macro using @kbd{@@register}. It is, of course,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 possible to yank some text into a register and execute it using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 @kbd{@@register}. Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@LF} will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 execute the last macro that was executed using @kbd{@@register}.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 Viper will automatically lowercase the register, so that pressing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 @kbd{SHIFT} key for @kbd{@@} will not create problems. This is for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 @kbd{@@} macros and @kbd{"p} @emph{only}. In the case of @kbd{y},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 @kbd{"Ayy} will append to @emph{register a}. For @kbd{[,],',`}, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 is an error to use a Uppercase register name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 @comment [ balance parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 @cindex viewing registers and markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 The contents of a register can be seen by @kbd{]register}. (@kbd{[textmarker}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 will show the contents of a textmarker).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 @comment ] balance parens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 @cindex last keyboard macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 The last keyboard macro can also be executed using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 @kbd{*}, and it can be yanked into a register using @kbd{@@!register}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 This is useful for Emacs style keyboard macros defined using @kbd{C-x(}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 and @kbd{C-x)}. Emacs keyboard macros have more capabilities.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 @xref{Keyboard Macros,,Keyboard Macros,emacs, The GNU Emacs Manual}, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 details.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 Keyboard Macros allow an interesting form of Query-Replace:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 @kbd{/pattern} or @kbd{n} to go to the next pattern (the query), followed by a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 Keyboard Macro execution @kbd{@@@@} (the replace).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 Viper also provides Vi-style macros. @xref{Vi Macros}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 @node Completion, Improved Search, Macros and Registers, Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 @section Completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 @cindex completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 Completion is done when you type @kbd{TAB}. The Emacs completer does not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 grok wildcards in filenames. Once you type a wildcard, the completer will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 no longer work for that path. Remember that Emacs interprets a file name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 of the form @kbd{/foo//bar} as @kbd{/bar} and @kbd{/foo/~/bar} as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 @kbd{~/bar}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 @node Improved Search, Abbreviation Facilities, Completion, Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 @section Improved Search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 @cindex buffer search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 @cindex word search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 Viper provides buffer search, the ability to search the buffer for a region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 under the cursor. You have to turn this on in @file{.vip} either by calling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (vip-buffer-search-enable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 or by setting @code{vip-buffer-search-char} to, say, @kbd{f3}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (setq vip-buffer-search-char [f3])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 If the user calls @code{vip-buffer-search-enable} explicitly (the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 method), then @code{vip-buffer-search-char} will be set to @kbd{g}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 Regardless of how this feature is enabled, the key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 @code{vip-buffer-search-char} will take movement commands, like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 @kbd{w,/,e}, to find a region and then search for the contents of that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 region. This command is very useful for searching for variable names, etc.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 in a program. The search can be repeated by @kbd{n} or reversed by @kbd{N}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 @cindex incremental search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 Emacs provides incremental search. As you type the string in, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 cursor will move to the next match. You can snarf words from the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 as you go along. Incremental Search is normally bound to @kbd{C-s} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 @kbd{C-r}. @xref{Customization}, to find out how to change the bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 of @kbd{C-r or C-s}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 For details, @pxref{Incremental Search,,Incremental
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 Search,emacs,The GNU Emacs Manual} @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 @cindex query replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 Viper also provides a query replace function that prompts through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 Minibuffer. It is invoked by the @kbd{Q} key in Vi state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 @cindex mouse search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 On a window display, Viper supports mouse search, i.e., you can search for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 word by clicking on it. @xref{Viper Specials}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 Finally, on a window display, Viper highlights search patterns as it finds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 them. This is done through what is known as @emph{faces} in Emacs. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 variable that controls how search patterns are highlighted is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 @code{vip-search-face}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 If you don't want any highlighting at all, put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (copy-face 'default 'vip-search-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 @vindex @code{vip-search-face}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 in @file{~/.vip}. If you want to change how patterns are highlighted, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 will have to set the variable @code{vip-search-face} to some other face,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 such as @code{highlight}. If none of the existing faces fits the bill, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 may have to create your own. Further details on faces can be found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 in the Emacs Lisp Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 @node Abbreviation Facilities,Movement and Markers,Improved Search,Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 @section Abbreviation Facilities
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 @cindex abbrevs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 It is possible in Emacs to define abbrevs based on the contents of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 Sophisticated templates can be defined using the Emacs abbreviation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 facilities. @xref{Abbrevs,,Abbreviations,emacs,The GNU Emacs Manual}, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 @cindex dynamic abbrevs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 Emacs also provides Dynamic Abbreviations. Given a partial word, Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 will search the buffer to find an extension for this word. For instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 one can type @samp{Abbreviations} by typing @samp{A}, followed by a keystroke
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 that completed the @samp{A} to @samp{Abbreviations}. Repeated typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 will search further back in the buffer, so that one could get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 @samp{Abbrevs} by repeating the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 keystroke, which appears earlier in the text. Emacs binds this to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 @kbd{ESC /}, so you will have to find a key and bind the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 @code{dabbrev-expand} to that key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 Facilities like this make Vi's @kbd{:ab} command obsolete.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 @node Movement and Markers, New Commands, Abbreviation Facilities, Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 @section Movement and Markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 @cindex Ex style motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 @cindex line editor motion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 Viper can be set free from the line--limited movements in Vi, such as @kbd{l}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 refusing to move beyond the line, @kbd{ESC} moving one character back,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 etc. These derive from Ex, which is a line editor. If your @file{.vip}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 contains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 @code{(setq vip-ex-style-motion nil)}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 the motion will be a true screen editor motion. One thing you must then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 watch out for is that it is possible to be on the end-of-line character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 The keys @kbd{x} and @kbd{%} will still work correctly, i.e., as if they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 were on the last character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 @vindex @code{vip-syntax-preference}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 @cindex syntax table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 The word-movement commands @kbd{w}, @kbd{e}, etc., and the associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 deletion/yanking commands, @kbd{dw}, @kbd{yw}, etc., can be made to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 understand Emacs syntax tables. If the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 @code{vip-syntax-preference} is set to @code{'strict-vi} (the default) then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 the meaning of @emph{word} is the same as in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 Vi. However, if the value is @code{'reformed-vi} then the alphanumeric
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 symbols will be those specified by the current Emacs syntax table (which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 may be different for different major modes) plus the underscore symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 @code{_}. The user can also specify the value @code{'emacs}, which would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 make Viper use exactly the Emacs notion of word. In particular, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 underscore may not be part of a word. Finally, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 @code{vip-syntax-preference} is set to @code{'extended}, Viper words would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 consist of characters that are classified as alphanumeric @emph{or} as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 parts of symbols. This is convenient for writing programs and in many other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 situations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 @code{vip-syntax-preference} is a local variable, so it can have different
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 values for different major modes. For instance, in programming modes it can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 have the value @code{'extended}. In text modes where words contain special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 characters, such as European (non-English) letters, Cyrillic letters, etc.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 the value can be @code{'reformed-vi} or @code{'emacs}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 Changes to @code{vip-syntax-preference} should be done in the hooks to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 various major modes. Furthermore, for these changes to take effect, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 should execute @code{(vip-update-alphanumeric-class)} right after changing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 The above discussion of the meaning of Viper's words concerns only Viper's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 movement commands. In regular expressions, words remain the same as in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 Emacs. That is, the expressions @code{\w}, @code{\>}, @code{\<}, etc., use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 Emacs' idea of what is a word, and they don't look into the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 variable @code{vip-syntax-preference}. This is because Viper doesn't change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 syntax tables in fear of upsetting the various major modes that set these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 @cindex textmarkers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 Textmarkers in Viper remember the file and the position, so that you can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 switch files by simply doing @kbd{'a}. If you set up a regimen for using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 Textmarkers, this is very useful. Contents of textmarkers can be viewed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 by @kbd{[marker}. (Contents of registers can be viewed by @kbd{]register}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 @node New Commands, Useful Packages, Movement and Markers, Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 @section New Commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 These commands have no Vi analogs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 @table @kbd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 @item C-x, C-c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 @kindex @kbd{C-x}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 @kindex @kbd{C-c}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 @kbd{C-x} will exit from Vi state and return to Emacs state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 @emph{temporarily}. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 you hit one of these keys, Emacs will believe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 that you hit that key in Emacs state. For example, if you hit @kbd{C-x}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 followed by @kbd{2}, then the current window will be split into 2 and you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 will be in Vi state again. Except for novice users, @kbd{C-c} is also set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 to temporarily escape to Emacs and execute a command from the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 @kbd{ESC} will do the same, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 you configure @key{ESC} as Meta by setting @code{vip-no-multiple-ESC} to nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 in @file{.vip}. @xref{Customization}. @kbd{C-z}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 in Insert state will make Emacs think @kbd{Meta} has been hit.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 @item \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 @kindex @kbd{\}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 Escape to Emacs to execute a single Emacs command. For instance, @kbd{\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 ESC} will act like a Meta key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 @item Q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 @kindex @kbd{Q}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 @cindex query replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 @kbd{Q} is for query replace. By default,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 each string to be replaced is treated as a regular expression. You can use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 @code{(setq vip-re-query-replace nil)} in your @file{.emacs} file to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 turn this off. (For normal searches, @kbd{:se nomagic} will work. Note
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 that @kbd{:se nomagic} turns Regexps off completely, unlike Vi).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 @item v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 @itemx V
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 @itemx C-v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 @kindex @kbd{v}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 @kindex @kbd{V}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 @kindex @kbd{C-v}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 These keys are used to visit files. @kbd{v} will switch to a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 visiting file whose name can be entered in the Minibuffer. @kbd{V} is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 similar, but will use a window different from the current window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 @kbd{C-v} is like @kbd{V}, except that a new frame (X window) will be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 instead of a new Emacs window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 @item #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 @kindex @kbd{#}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 If followed by a certain character @var{ch}, it becomes an operator whose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 argument is the region determined by the motion command that follows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (indicated as <move>).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 Currently, @var{ch} can be one of @kbd{c}, @kbd{C}, @kbd{g}, @kbd{q}, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 @kbd{s}. For instance, @kbd{#qr} will prompt you for a string and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 prepend this string to each line in the buffer.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 @item # c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 @kindex @kbd{#c<move>}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 @cindex changing case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 Change upper case characters in the region to lower case
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (@code{downcase-region}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 Emacs command @kbd{M-l} does the same for words.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 @item # C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 @kindex @kbd{#C<move>}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 Change lower case characters in the region to upper case. For instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 @kbd{# C 3 w} will capitalize 3 words from the current point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (@code{upcase-region}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 Emacs command @kbd{M-u} does the same for words.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 @item # g
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 @kindex @kbd{#g<move>}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 Execute last keyboard macro for each line in the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (@code{vip-global-execute}).@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 @item # q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 @kindex @kbd{#q<move>}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 Insert specified string at the beginning of each line in the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (@code{vip-quote-region}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 @item # s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 @kindex @kbd{#s<move>}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 Check spelling of words in the region (@code{spell-region}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 The function used for spelling is determined from the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 @code{vip-spell-function}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 @vindex @code{vip-spell-function}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 @item *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 @kindex @kbd{*}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 Call last keyboard macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 @item m .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 Set mark at point and push old mark off the ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 @item m<
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 @item m>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 Set mark at beginning and end of buffer, respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 @item m,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 Jump to mark and pop mark off the ring. @xref{Mark,,Mark,emacs,The GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 Emacs Manual}, for more info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 @item ] register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 @kindex @kbd{]<a-z>}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 View contents of register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 @item [ textmarker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 @kindex @kbd{[<a-z>}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 View filename and position of textmarker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 @item @@#
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 @item @@register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 @item @@!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 @kindex @kbd{@@#}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 @kindex @kbd{@@<a-z>}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 @kindex @kbd{@@!}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 @cindex keyboard macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 @cindex register execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 Begin/end keyboard macro. @@register has a different meaning when used after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 a @kbd{@@#}. @xref{Macros and Registers}, for details
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 @item []
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 @kindex @kbd{[]}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 Go to end of heading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 @item g <@emph{movement command}>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 Search buffer for text delimited by movement command. The canonical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 example is @kbd{gw} to search for the word under the cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 @xref{Improved Search}, for details.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 @item _
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 @kindex @kbd{_}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 Meta key when in Vi state.@xref{Vi State}, for an explanation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 @item C-g and C-]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 @kindex @kbd{C-g}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 @kindex @kbd{C-]}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 Quit and Abort Recursive edit. These may be necessary on occasion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 @xref{Vi State}, for a reason.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 @item C-c g
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 @kindex @kbd{C-c g}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 Hitting @kbd{C-c} followed by @kbd{g} will display the information on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 current buffer. This is the same as hitting @kbd{C-g} in Vi, but, as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 explained above, @kbd{C-g} is needed for other purposes in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 @item C-c /
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 @kindex @kbd{C-c /}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 Without a prefix argument, this command toggles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 case-sensitive/case-insensitive search modes and plain vanilla/regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 expression search. With the prefix argument 1, i.e.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 @kbd{1 C-c /}, this toggles case-sensitivity; with the prefix argument 2,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 toggles plain vanilla search and search using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 regular expressions. @xref{Viper Specials}, for alternative ways to invoke
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 @cindex vanilla search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 @cindex case-sensitive search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 @cindex case-insensitive search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 @item M-p and M-n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 @kindex @kbd{M-p}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 @kindex @kbd{M-n}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 In the Minibuffer, these commands navigate through the minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 histories, such as the history of search strings, Ex commands, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 @item C-c M-p and C-c M-n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 @kindex @kbd{C-c M-p}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 @kindex @kbd{C-c M-n}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 @cindex Insertion history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 @cindex Insertion ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 @cindex Command history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 @cindex Command ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 In Insert or Replace state, these commands let the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 peruse the history of insertion strings used in previous insert or replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 commands. Try to hit @kbd{C-c M-p} or @kbd{C-c M-n} repeatedly and see what
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 happens. @xref{Viper Specials}, for more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 In Vi state, these commands let the user peruse the history of Vi-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 destructive commands, such as @kbd{dw}, @kbd{J}, @kbd{a}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 By repeatedly typing @kbd{C-c M-p} or @kbd{C-c M-n} you will cycle Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 through the recent history of Vi commands, displaying the commands one by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 one. Once
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 an appropriate command is found, it can be executed by typing `@kbd{.}'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 Since typing @kbd{C-c M-p} is tedious, it is more convenient to bind an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 appropriate function to a function key on the keyboard and use that key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 @xref{Viper Specials}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 @item Ex commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 @findex @kbd{:args}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 @findex @kbd{:n}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 @findex @kbd{:pwd}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 @findex @kbd{:pre}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 The commands @kbd{:args}, @kbd{:next}, @kbd{:pre} behave
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 differently. @kbd{:pwd} exists to get current directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 The commands @kbd{:b} and @kbd{:B} switch buffers around. @xref{File and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 Buffer Handling}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 There are also the new commands @kbd{:RelatedFile} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 @kbd{PreviousRelatedFile} (which abbreviate to @kbd{R} and @kbd{P},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 respectively. @xref{Viper Specials}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 @findex @kbd{:RelatedFile}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 @findex @kbd{:PreviousRelatedFile}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 Apart from the new commands, many old commands have been enhanced. Most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 notably, Vi style macros are much more powerful in Viper than in Vi. @xref{Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 Macros}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 @node Useful Packages, ,New Commands, Improvements over Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 @section Useful Packages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 Some Emacs packages are mentioned here as an aid to the new Viper user, to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 indicate what Viper is capable of.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 A vast number comes with the standard Emacs distribution, and many more exist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 on the net and on the archives.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 This manual also mentions some Emacs features a new user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 should know about. The details of these are found in the GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 The features first. For details, look up the Emacs Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 @table @samp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 @item Make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 @cindex make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 @cindex compiling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 Makes and Compiles can be done from the editor. Error messages will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 parsed and you can move to the error lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 @item Shell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 @cindex shell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 @cindex interactive shell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 You can talk to Shells from inside the editor. Your entire shell session
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 can be treated as a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 @item Mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 @cindex email
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 @cindex mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 Mail can be read from and sent within the editor. Several sophisticated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 packages exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 @item Language Sensitive Editing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 Editing modes are written for most computer languages in existence. By
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 controlling indentation, they catch punctuation errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 The packages, below, represents a drop in the sea of special-purpose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 packages that come with standard distribution of Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 @table @samp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 @item Transparent FTP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 @cindex transparent ftp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 @pindex ange-ftp.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 @code{ange-ftp.el} can ftp from the editor to files on other machines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 transparent to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 @item RCS Interfaces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 @cindex version maintenance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 @cindex RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 @pindex vc.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 @code{vc.el} for doing RCS commands from inside the editor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 @item Directory Editor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 @cindex dired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 @pindex dired.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 @code{dired.el} for editing contents of directories and for navigating in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 the file system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 @item Syntactic Highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 @cindex hilit19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 @pindex hilit19.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 @cindex font-lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 @pindex font-lock.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 @code{hilit19.el} and @code{font-lock.el} for automatic highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 various parts of a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 using different fonts and colors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 @item Saving Emacs Configuration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 @cindex desktop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 @pindex desktop.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 @code{desktop.el} for saving/restoring configuration on Emacs exit/startup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 @item Spell Checker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 @cindex ispell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 @pindex ispell.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 @code{ispell.el} for spell checking the buffer, words, regions, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 @item File and Buffer Comparison
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 @cindex ediff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 @pindex ediff.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 @code{ediff.el} for finding differences between files and for applying
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 patches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 Emacs Lisp archives exist on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 @samp{archive.cis.ohio-state.edu}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 and @samp{wuarchive.wustl.edu}@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 @node Customization,Commands,Improvements over Vi,Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 @chapter Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 @cindex customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 Customization can be done in 2 ways.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 @itemize @bullet
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 @cindex initialization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 @cindex .vip
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 Elisp code in a @file{.vip} file in your home directory. Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 loads @file{.vip} just before it does the binding for mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 hooks. This is the recommended method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 @item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 @cindex .emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 Elisp code in your @file{.emacs} file before and after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 @code{(require 'viper)} line. This method is not recommended, unless you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 are know what you are doing.@refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 @end itemize
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 Emacs customization is done in Emacs Lisp. For the common cases,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 examples are provided that you can use directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 * Rudimentary Changes:: Simple constant definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 * Keybindings:: Enabling Emacs Keys, Rebinding keys, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 * Packages that Change Keymaps:: How to deal with such beasts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 * Viper Specials:: Special Viper commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 * Vi Macros:: How to do Vi style macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 @node Rudimentary Changes,Keybindings,Customization,Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 @section Rudimentary Changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 @cindex setting variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 @cindex variables for customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 @findex @kbd{:set}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 An easy way to customize Viper is to change the values of constants used in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 Viper. Here is the list of the constants used in Viper and their default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 values. The corresponding :se command is also indicated. (The symbols
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 @code{t} and @code{nil} represent ``true'' and ``false'' in Lisp).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 Viper supports both the abbreviated Vi variable names and their full
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 names. Variable completion is done on full names only. @kbd{TAB} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 @kbd{SPC} complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 variable names. Typing `=' will complete the name and then will prompt for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 a value, if applicable. For instance, @kbd{:se auSPC} will complete the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 command to @kbd{:set autoindent}; @kbd{:se taSPC} will complete the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 and prompt further like this: @kbd{:set tabstop = }.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 However, typing @kbd{:se tsSPC} will produce a ``No match'' message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 because @kbd{ts} is an abbreviation for @kbd{tabstop} and Viper supports
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 completion on full names only. However, you can still hit @kbd{RET}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 or @kbd{=}, which will complete the command like this: @kbd{:set ts = } and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 Viper will be waiting for you to type a value for the tabstop variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 To get the full list of Vi variables, type @kbd{:se SPC TAB}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 @item vip-auto-indent nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 @itemx :se ai (:se autoindent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 @itemx :se gai (:se global-autoindent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 If @code{t}, enable auto indentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 by @kbd{RET}, @kbd{o} or @kbd{O} command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 @code{vip-auto-indent} is a local variable. To change the value globally, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 @code{setq-default}. It may be useful for certain major modes to have their
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 own values of @code{vip-auto-indent}. This can be achieved by using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 @code{setq} to change the local value of this variable in the hooks to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 appropriate major modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 @kbd{:se ai} changes the value of @code{vip-auto-indent} in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 buffer only; @kbd{:se gai} does the same globally.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 @item vip-electric-mode t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 If @code{t}, auto-indentation becomes electric, which means that @kbd{RET},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 @kbd{O}, and @kbd{o} indent cursor according to the current major mode. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 the future, this variable may control additional electric features.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 This is a local variable: @code{setq} changes the value of this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 in the current buffer only. Use @code{setq-default} to change the value in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 all buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 @item vip-case-fold-search nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 @itemx :se ic (:se ignorecase)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 If @code{t}, search ignores cases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 This can also be toggled by quickly hitting @kbd{/} twice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 @item vip-re-search nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 @itemx :se magic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 If @code{t} then search is reg-exp search, if @code{nil} then vanilla
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 This behavior can also be toggled by quickly hitting @kbd{/} trice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 @item buffer-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 @itemx :se ro (:se readonly)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 Set current buffer to read only. To change globally put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 @code{(setq-default buffer-read-only t)} in your @file{.emacs} file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 @item blink-matching-paren t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 @itemx :se sm (:se showmatch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 Show matching parens by blinking cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 @item tab-width t (default setting via @code{setq-default})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 @itemx :se ts=value (:se tabstop=value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 @itemx :se gts=value (:se global-tabstop=value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 @code{tab-width} is a local variable that controls the width of the tab stops.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 To change the value globally, use @code{setq-default}; for local settings,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 use @code{setq}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 The command @kbd{:se ts}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 sets the tab width in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 buffer only; it has no effect on other buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 The command @kbd{:se gts} sets tab width globally,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 for all buffers where the tab is not yet set locally,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 including the new buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 Note that typing @kbd{TAB} normally
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 doesn't insert the tab, since this key is usually bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 a text-formatting function, @code{indent-for-tab-command} (which facilitates
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 programming and document writing). Instead, the tab is inserted via the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 command @code{vip-insert-tab}, which is bound to @kbd{S-tab} (shift + tab).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 On some non-windowing terminals, Shift doesn't modify the @kbd{TAB} key, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 @kbd{S-tab} behaves as if it were @kbd{TAB}. In such a case, you will have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 to bind @code{vip-insert-tab} to some other convenient key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 @item vip-shift-width 8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 @itemx :se sw=value (:se shiftwidth=value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 The number of columns shifted by @kbd{>} and @kbd{<} commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 @item vip-search-wrap-around t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 @itemx :se ws (:se wrapscan)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 If @code{t}, search wraps around the end/beginning of buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 @item vip-tags-file-name "TAGS"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 The name of the file used as the tag table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 @item vip-re-query-replace nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 If @code{t}, use reg-exp replace in query replace.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 @item vip-want-ctl-h-help nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 If @code{t}, @kbd{C-h} is bound to @code{help-command};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 if @code{nil}, it is bound to @code{delete-backward-char}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 @item vip-vi-style-in-minibuffer t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 If @code{t}, Viper provides a high degree of compatibility with Vi insert mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 when you type text in the Minibuffer; if @code{nil}, typing in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 Minibuffer feels like plain Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 @item vip-no-multiple-ESC t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 If you set this to @code{nil}, you can use @kbd{ESC} as Meta in Vi state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 Normally, this is not necessary, since graphical displays have separate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 Meta keys (usually on each side of the space bar). On a dumb terminal, Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 sets this variable to @code{twice}, which is almost like @code{nil}, except
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 that double @kbd{ESC} beeps. This, too, lets ESC to be used as a Meta.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 @item vip-keysequence-delay 140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 Escape sequences separated by this much delay are interpreted as command,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 ignoring the special meaning of ESC in VI. The default is suitable for most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 terminals. However, if your terminal is extremely slow, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 might want to increase this slightly. You will know if your terminal is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 slow if the ESC key sequences emitted by the arrow keys are interpreted as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 separately typed characters (and thus the arrow keys won't work).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 Making this value too large will slow you down, so exercise restraint.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 @item vip-ex-style-motion t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 Set this to @code{nil}, if you want @kbd{l,h} to cross
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 lines, etc. @xref{Movement and Markers}, for more info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 @item vip-ex-style-editing-in-insert t
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1706 Set this to @code{nil}, if you want @kbd{ESC} to not move back and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 @kbd{C-h} to not stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 at the beginning of a line in Insert state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 @item vip-always t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 Leave it to Viper to decide when a buffer must be brought up in Vi state,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 Insert state, or Emacs state. This heuristics works well in virtually all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 cases.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 This option must be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 set before Viper is loaded or in the @file{.vip} file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 @item vip-custom-file-name "~/.vip"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 Change this if you want. Must be set in @file{.emacs} (not @file{.vip}!)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 before Viper is loaded. Note that you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 have to set it as a string inside double quotes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 @item vip-spell-function 'ispell-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 Function used by the command @kbd{#c<move>} to spell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 @item ex-nontrivial-find-file-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 The value of this variable is the function used to find all files that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 match a wildcard. This is usually done when the user types @kbd{:e} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 specifies a wildcard in the file name (or if the file name contains unusual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 symbols (e.g., a space). Viper provides two functions for this: one for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 Unix-like systems (@code{vip-ex-nontrivial-find-file-unix}) and one for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 DOS, W95, and NT (@code{vip-ex-nontrivial-find-file-ms}). If the default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 function doesn't quite do what you expect or if you prefer to use ``fancy''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 shells, you may have to write your own version of this function and make it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 into the value of @code{ex-nontrivial-find-file-function}. Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 @code{vip-ex-nontrivial-find-file-unix} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 @code{vip-ex-nontrivial-find-file-ms} as examples.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 @vindex @code{ex-nontrivial-find-file-function}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 @findex @code{vip-ex-nontrivial-find-file-ms}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 @findex @code{vip-ex-nontrivial-find-file-unix}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 @item ex-cycle-other-window t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 If @code{t}, @kbd{:n} and @kbd{:b} will cycle through files in another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 window, if one exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 @item ex-cycle-through-non-files nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 @kbd{:n} does not normally cycle through buffers. Set this to get
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 buffers also.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 @item vip-automatic-iso-accents nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 If @kbd{t}, ISO accents will be turned on in insert/replace Viper states
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 and turned off in Vi state. This is useful for editing text in European
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 languages. This variable is buffer-local. If used, it should be set in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 hooks to the appropriate major modes (usually setting it in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 @code{text-mode-hook} is enough).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 @item vip-want-emacs-keys-in-insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 This is set to @code{nil} for user levels 1 and 2 and to @code{t} for user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 levels 3 and 4. Users who specify level 5 are allowed to set this variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 as they please (the default for this level is @code{t}). If set to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 @code{nil}, complete Vi compatibility is provided in Insert state. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 really not recommended, as this precludes you from using language-specific
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 features provided by the major modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 @item vip-want-emacs-keys-in-vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 This is set to @code{nil} for user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 level 1 and to @code{t} for user levels 2--4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 At level 5, users are allowed to set this variable as they please (the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 default for this level is @code{t}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 If set to @code{nil}, complete Vi compatibility is provided
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 in Vi command state. Setting this to @code{nil} is really a bad idea,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 unless you are a novice, as this precludes the use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 of language-specific features provided by the major modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 @item vip-keep-point-on-repeat t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 If @code{t}, point is not moved when the user repeats the previous command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 by typing `.' This is very useful for doing repeated changes with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 @kbd{.} key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 @item vip-repeat-from-history-key 'f12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 Prefix key used to invoke the macros @kbd{f12 1} and @kbd{f12 2} that repeat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 the second-last and the third-last destructive command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 Both these macros are bound (as Viper macros) to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 @code{vip-repeat-from-history},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 which checks the second key by which it is invoked to see which of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 previous commands to invoke. Viper binds @kbd{f12 1} and @kbd{f12 2} only,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 but the user can bind more in @file{~/.vip}. @xref{Vi Macros}, for how to do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 @item vip-keep-point-on-undo nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 If @code{t}, Viper tries to not move point when undoing commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 Instead, it will briefly move the cursor to the place where change has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 taken place. However, if the undone piece of text is not seen in window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 then point will be moved to the place where the change took place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 Set it to @code{t} and see if you like it better.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 @item vip-delete-backwards-in-replace nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 If @code{t}, DEL key will delete characters while moving the cursor backwards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 If @code{nil}, the cursor will move backwards without deleting anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 @item vip-replace-overlay-face 'vip-replace-overlay-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 On a graphical display, Viper highlights replacement regions instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 putting a @samp{$} at the end. This variable controls the so called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 @dfn{face} used to highlight the region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 By default, @code{vip-replace-overlay-face} underlines the replacement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 on monochrome displays and highlights it with color on color displays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 If you know something about Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 faces and don't like how Viper highlights replacement regions, you can change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 this variable to specify a new face name. (Emacs faces are described in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 Emacs Lisp reference.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 On a color display, the following customization method is usually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 most effective:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (set-face-foreground vip-replace-overlay-face "DarkSlateBlue")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 (set-face-background vip-replace-overlay-face "yellow")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 For a complete list of colors available to you, evaluate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 expression @code{(x-defined-colors)}. (Type it in the buffer @code{*scratch*}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 and then hit the @kbd{C-j} key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 @item vip-replace-overlay-cursor-color "Red"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 Cursor color when it is inside the replacement region.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 This has effect only on color displays and only when Emacs runs as an X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 application.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 @item vip-replace-region-end-delimiter "$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 A string used to mark the end of replacement regions. It is used only with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 TTYs or if @code{vip-use-replace-region-delimiters} is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 @item vip-replace-region-start-delimiter ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 A string used to mark the beginning of replacement regions. It is used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 only with TTYs or if @code{vip-use-replace-region-delimiters} is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 @item vip-use-replace-region-delimiters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 If non-nil, Viper will always use @code{vip-replace-region-end-delimiter} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 @code{vip-replace-region-start-delimiter} to delimit replacement regions,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 even on color displays (where this is unnecessary). By default, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 variable is non-nil only on TTYs or monochrome displays.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 @item vip-toggle-key "\C-z"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 Specifies the key used to switch from Emacs to Vi and back.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 Must be set in @file{.vip} or prior to loading Viper. This variable can't be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 changed interactively after Viper is loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 @item vip-ESC-key "\e"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 Specifies the key used to escape from Insert/Replace states to Vi.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 Must be set in @file{.vip} or prior to loading Viper. This variable cannot be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 changed interactively after Viper is loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 @item vip-buffer-search-char nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 Key used for buffer search. @xref{Viper Specials}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 @item vip-surrounding-word-function 'vip-surrounding-word
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 The value of this variable is a function name that is used to determine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 what constitutes a word clicked upon by the mouse. This is used by mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 search and insert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 @item vip-search-face 'vip-search-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 Variable that controls how search patterns are highlighted when they are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 @item vip-vi-state-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 List of parameterless functions to be run just after entering the Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 command state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 @item vip-insert-state-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 Same for Insert state. This hook is also run after entering Replace state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 @item vip-replace-state-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 List of (parameterless) functions called just after entering Replace state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (and after all @code{vip-insert-state-hook}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 @item vip-emacs-state-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 List of (parameterless) functions called just after switching from Vi state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 to Emacs state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 @item vip-load-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 List of (parameterless) functions called just after loading Viper. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 the last chance to do customization before Viper is up and running.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 You can reset some of these constants in Viper with the Ex command @kbd{:set}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (when so indicated in the table). Or you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 can include a line like this in your @file{.vip} file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 (setq vip-case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 @vindex @code{vip-auto-indent}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 @vindex @code{vip-electric-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 @vindex @code{vip-case-fold-search}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 @vindex @code{vip-re-search}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 @vindex @code{vip-shift-width}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 @vindex @code{buffer-read-only}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 @vindex @code{vip-search-wrap-around}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 @vindex @code{vip-search-face}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 @vindex @code{vip-tags-file-name}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 @vindex @code{vip-re-query-replace}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 @vindex @code{vip-want-ctl-h-help}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 @vindex @code{vip-vi-style-in-minibuffer}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 @vindex @code{vip-no-multiple-ESC}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 @vindex @code{vip-always}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 @vindex @code{vip-keysequence-delay}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 @vindex @code{vip-ex-style-motion}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 @vindex @code{vip-ex-style-editing-in-insert}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 @vindex @code{vip-custom-file-name}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 @vindex @code{vip-spell-function}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 @vindex @code{ex-cycle-other-window}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 @vindex @code{ex-cycle-through-non-files}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 @vindex @code{vip-automatic-iso-accents}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 @vindex @code{vip-want-emacs-keys-in-insert}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 @vindex @code{vip-want-emacs-keys-in-vi}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 @vindex @code{vip-keep-point-on-repeat}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 @vindex @code{vip-keep-point-on-undo}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 @vindex @code{vip-delete-backwards-in-replace}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 @vindex @code{vip-replace-overlay-face}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 @vindex @code{vip-replace-region-end-symbol}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 @vindex @code{vip-replace-region-start-symbol}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 @vindex @code{vip-toggle-key}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 @vindex @code{vip-ESC-key}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 @vindex @code{vip-buffer-search-char}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 @vindex @code{vip-surrounding-word-function}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 @vindex @code{vip-vi-state-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 @vindex @code{vip-insert-state-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 @vindex @code{vip-replace-state-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 @vindex @code{vip-emacs-state-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 @node Keybindings, Packages that Change Keymaps, Rudimentary Changes,Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 @section Keybindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 @cindex keybindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 @cindex keymaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 Viper lets you define hot keys, i.e., you can associate keyboard keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 such as F1, Help, PgDn, etc., with Emacs Lisp functions (that may already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 exist or that you will write). Each key has a "preferred form" in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 Emacs. For instance, the Up key's preferred form is [up], the Help key's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 preferred form is [help], and the Undo key has the preferred form [f14].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 You can find out the preferred form of a key by typing @kbd{M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 describe-key-briefly} and then typing the key you want to know about.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 Under X Windows, every keyboard key emits its preferred form, so you can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 just type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (global-set-key [f11] 'calendar) ; L1, Stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (global-set-key [f14] 'undo) ; L4, Undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 to bind L1 so it will invoke the Emacs Calendar and to bind L4 so it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 undo changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 However, on a dumb terminal or in an Xterm window, even the standard arrow
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 keys may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 not emit the right signals for Emacs to understand. To let Emacs know about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 those keys, you will have to find out which key sequences they emit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 by typing @kbd{C-q} and then the key (you should switch to Emacs state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 first). Then you can bind those sequences to their preferred forms using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 @code{function-key-map} as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (cond ((string= (getenv "TERM") "xterm")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (define-key function-key-map "\e[192z" [f11]) ; L1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (define-key function-key-map "\e[195z" [f14]) ; L4, Undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 The above illustrates how to do this for Xterm. On VT100, you would have to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 replace "xterm" with "vt100" and also change the key sequences (the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 key may emit different sequences on different types of terminals).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 The above keys are global, so they are overwritten by the local maps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 defined by the major modes and by Viper itself. Therefore, if you wish to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 change a binding set by a major mode or by Viper, read this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 Viper users who wish to specify their own key bindings should be concerned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 only with the following three keymaps:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 @code{vip-vi-global-user-map} for Vi state commands,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 @code{vip-insert-global-user-map} for Insert state commands,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 and @code{vip-emacs-global-user-map} for Emacs state commands (note:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 customized bindings for Emacs state made to @code{vip-emacs-global-user-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 are @emph{not} inherited by Insert state).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 For more information on Viper keymaps, see the header of the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 @file{viper.el}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 If you wish to change a Viper binding, you can use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 @code{define-key} command, to modify @code{vip-vi-global-user-map},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 @code{vip-insert-global-user-map}, and @code{vip-emacs-global-user-map}, as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 explained below. Each of these key maps affects the corresponding Viper state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 The keymap @code{vip-vi-global-user-map} also affects Viper's Replace state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 If you want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 bind a key, say @kbd{C-v}, to the function that scrolls
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 page down and to make @kbd{0} display information on the current buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 putting this in @file{.vip} will do the trick in Vi state:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (define-key vip-vi-global-user-map "\C-v" 'scroll-down)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 To set a key globally,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 (define-key vip-emacs-global-user-map "\C-c m" 'smail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (define-key vip-vi-global-user-map "0" 'vip-info-on-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 Note, however, that this binding may be overwritten by other keymaps, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 the global keymap has the lowest priority.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 To make sure that nothing will override a binding in Emacs state, you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 can write this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 (define-key vip-emacs-global-user-map "\C-c m" 'smail)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 To customize the binding for @kbd{C-h} in Insert state:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (define-key vip-insert-global-user-map "\C-h" 'my-del-backwards-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 Each Emacs command key calls some lisp function. If you have enabled the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 Help, (@xref{Rudimentary Changes}) @kbd{C-h k} will show you the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 for each specific key; @kbd{C-h b} will show all bindings, and @kbd{C-h m}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 will provide information on the major mode in effect. If Help is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 enabled, you can still get help in Vi state by prefixing the above commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 with @kbd{\}, e.g., @kbd{\ C-h k} (or you can use the Help menu in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 menu bar, if Emacs runs under X Windows).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 Viper users can also change bindings on a per major mode basis. As with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 global bindings, this can be done separately for each of the three main Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 states. To this end, Viper provides the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 @code{vip-modify-major-mode}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 @findex @code{vip-modify-major-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 To modify keys in Emacs state for @code{my-favorite-major-mode}, the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 needs to create a sparse keymap, say, @code{my-fancy-map}, bind whatever
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 keys necessary in that keymap, and put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (vip-modify-major-mode 'dired-mode 'emacs-state my-fancy-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 in @file{~/.vip}. To do the same in Vi and Insert states, one should use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 @code{vi-state} and @code{insert-state}. Changes in Insert state are also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 in effect in Replace state. For instance, suppose that the user wants to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 use @kbd{dd} in Vi state under Dired mode to delete files, @kbd{u} to unmark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 files, etc. The following code in @file{~/.vip} will then do the job:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (setq my-dired-modifier-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (define-key my-dired-modifier-map "dd" 'dired-flag-file-deletion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (define-key my-dired-modifier-map "u" 'dired-unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 (vip-modify-major-mode 'dired-mode 'vi-state my-dired-modifier-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 A Vi purist may want to modify Emacs state under Dired mode so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 @kbd{k}, @kbd{l}, etc., will move around in directory buffers, as in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 Vi. Although this is not recommended, as these keys are bound to useful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 Dired functions, the trick can be accomplished via the following code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (setq my-dired-vi-purist-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 (define-key my-dired-vi-purist-map "k" 'vip-previous-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (define-key my-dired-vi-purist-map "l" 'vip-forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 (vip-modify-major-mode 'dired-mode 'emacs-state my-dired-vi-purist-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 Similar effect can be achieved by defining Vi keyboard macros using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 Ex commands @kbd{:map} and @kbd{:map!}. The difference is that multi-key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 Vi macros do not override the keys they are bound to, unless these keys are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 typed in quick succession. So, with macros, one can use the normal keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 alongside with the macros. If per-mode modifications are needed, the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 can try both ways and see which one is more convenient.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 @findex @kbd{:map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 @xref{Vi Macros}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 Note: in major modes that come up in @emph{Emacs state} by default, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 aforesaid modifications may not take place immediately (but only after the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 buffer switches to some other Viper state and then back to Emacs state). To
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 avoid this, one should add @code{vip-change-state-to-emacs} to an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 appropriate hook of that major mode. (Check the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 @code{vip-set-hooks} in @file{viper.el} for examples.) However, if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 have set @code{vip-always} to @code{t}, chances are that you won't need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 perform the above procedure, because Viper will take care of most useful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 defaults.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 Finally, Viper has a facility that lets the user define per-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 bindings, i.e., bindings that are in effect in some specific buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 only. Unlike per-mode bindings described above, per-buffer bindings can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 defined based on considerations other than the major mode. This is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 via the function @code{vip-add-local-keys}, which lets one specify bindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 that should be in effect in the current buffer only and for a specific Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 state. For instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (vip-add-local-keys 'vi-state '(("ZZ" . TeX-command-master)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 ("ZQ" . vip-save-kill-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 redefines @kbd{ZZ} to invoke @code{TeX-command-master} in @code{vi-state}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 and @kbd{ZQ} to save-then-kill the current buffer. These bindings take
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 effect only in the buffer where this command is executed. The typical use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 of this function is to execute the above expression from within a function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 that is included in a hook to some major mode. For instance, the above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 expression
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 could be called from a function, @code{my-tex-init}, which may be added to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 @code{tex-mode-hook} as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (add-hook 'tex-mode-hook 'my-tex-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 When TeX mode starts, the hook is executed and the above Lisp expression is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 evaluated. Then, the bindings for @kbd{ZZ} and @kbd{ZQ} are changed in Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 command mode for all buffers in TeX mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 Another useful application is to bind @kbd{ZZ} to @code{send-mail}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 in the Mail mode buffers (the specifics of this depend on which mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 package you are using, @code{rmail}, @code{mh-e}, @code{vm}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 For instance, here is how to do this for @code{mh-e}, the Emacs interface
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 to MH:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 (defun mh-add-vi-keys ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 "Set up ZZ for MH-e and XMH."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 (vip-add-local-keys 'vi-state '(("ZZ" . mh-send-letter))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (add-hook 'mh-letter-mode-hook 'mh-add-vi-keys)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 You can also use @code{vip-add-local-keys} to set per buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 bindings in Insert state and Emacs state by passing as a parameter the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 symbols @code{'insert-state} and @code{'emacs-state}, respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 As with global bindings, customized local bindings done to Emacs state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 are not inherited by Insert state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 On rare occasions, local keys may be added by mistake. Usually this is done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 indirectly, by invoking a major mode that adds local keys (e.g.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 @code{shell-mode} redefines @kbd{RET}). In such a case, exiting the wrong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 major mode won't rid you from unwanted local keys, since these keys are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 local to Viper state and the current buffer, not to the major mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110 In such situations, the remedy is to type @kbd{M-x vip-zap-local-keys}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 So much about Viper-specific bindings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 @xref{Customization,,Customization,emacs,The GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 Manual}, and the Emacs quick reference card for the general info on key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 bindings in Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 @vindex @code{function-key-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 @vindex @code{vip-vi-global-user-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 @vindex @code{vip-insert-global-user-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 @vindex @code{vip-emacs-global-user-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 @findex @code{vip-add-local-keys}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 @findex @code{vip-zap-local-keys}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 @node Packages that Change Keymaps,Viper Specials,Keybindings,Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 @subsection Packages that Change Keymaps
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 @cindex C-c and Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 @cindex Viper and C-c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 Viper is designed to coexist with all major and minor modes of Emacs. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 means that bindings set by those modes are generally available with Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 (unless you explicitly prohibit them by setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 @code{vip-want-emacs-keys-in-vi} and @code{vip-want-emacs-keys-in-insert} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133 @code{nil}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 If @code{vip-always} is set to @code{t}, Viper will try to bring each buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 in the a Viper state that is most appropriate for that buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 Usually, this would be the Vi state, but sometimes it could be the Insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 state or the Emacs state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 Some major mode bindings will necessarily be overwritten by Viper. Indeed, in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 Vi state, most of the 1-character keys are used for Vi-style editing. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 usually causes no problems because most packages designed for editing files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 typically do not bind such keys. Instead, they use key sequences that start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 with @kbd{C-x} and @kbd{C-c}. This is why it was so important for us to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 free up @kbd{C-x} and @kbd{C-c}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 It is common for language-specific major modes to bind @kbd{TAB} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 @kbd{LFD} (the line feed) keys to various formatting functions. This is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 extremely useful, but may require some getting used to for a Vi user. If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 decide that this feature is not for you, you can re-bind these keys as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 explained earlier (@xref{Customization}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 Binding for @kbd{TAB} is one of the most unusual aspects of Viper for many
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152 novice users. In Emacs, @kbd{TAB} is used to format text and programs, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 is extremely useful. For instance, hitting @kbd{TAB} causes the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 line to be re-indented in accordance with the context. In programming,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155 this is very important, since improper automatic indentation would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 immediately alert the programmer to a possible error. For instance, if a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157 @kbd{)} or a @kbd{"} is missing somewhere above the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 line, @kbd{TAB} is likely to mis-indent the line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160 For this reason, Viper doesn't change the standard Emacs binding of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 @kbd{TAB}, thereby sacrificing Vi compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 (except for users at level 1). Instead, in Viper, the key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 @kbd{S-tab} (shift+ tab) is chosen to emulate Vi's @kbd{TAB}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 We should note that on some non-windowing terminals, Shift doesn't modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 the @kbd{TAB} key, so @kbd{S-tab} behaves as if it were @kbd{TAB}. In such
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 a case, you will have to bind @code{vip-insert-tab} to some other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 convenient key.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 Some packages, notably Dired, Gnus, Info, etc., attach special meaning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 to common keys like @kbd{SPC}, @kbd{x}, @kbd{d}, @kbd{v}, and others. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 means that Vi command state is inappropriate for working with these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 packages. Fortunately, these modes operate on read-only buffers and are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 designed not for editing files, but for special-purpose browsing, reading
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 news, mail, etc., and Vi commands are meaningless in these situations. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 this reason, Viper doesn't force Vi state on such major modes. Rather, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 brings them in Emacs state. You can switch to Vi state by typing @kbd{C-z}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 if, for instance, you want to do Vi-style search in a buffer (although,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 usually, incremental search, which is bound to @kbd{C-s}, is sufficient in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 these situations). But you should then switch back to Emacs state if you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 plan to continue using these major modes productively. You can also switch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 to Vi temporarily, to execute one 1-character command. This is done by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 typing @kbd{M-C-z} (or @kbd{ESC C-z}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 This facility cannot execute several complex Vi commands, such as @kbd{dw},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 @kbd{de}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 It is also possible to harness some major modes, even though they may bind
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 common keys to specialized commands. Harnessing can make sense for modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 that bind only a small number of common keys. For instance, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 @code{vip-always} is set to @code{t} in your @file{~/.vip} file, Viper will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 harness the Shell mode by changing the bindings for @kbd{C-m} and @kbd{C-d}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 using @code{vip-add-local-keys} described in section on customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 (@xref{Customization}). In general, there is no single recipe for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 harnessing modes. It can be as simple as adding the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 @code{viper-mode} to a hook associated with the mode, or it can be more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 complex, as in the case of Shell mode and Emerge. Take a look at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 @code{vip-set-hooks} function for some examples.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 Conversely, it may be the case that most of the major modes harnessed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 by @code{vip-set-hooks} function fit your working style, except one or two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 cases. In this case, you may still be able to set @code{vip-always} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 @code{t} and then remove a hook that forces Vi command state. For instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 to unharness @code{lisp-interaction-mode}, you can put the following line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 in your @file{.emacs} (not @code{.vip}!) file after @code{(require 'viper)}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (remove-hook 'lisp-interaction-mode-hook 'viper-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209 In some rare cases, some minor modes may override certain essential
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 bindings in Vi command state. This is not really catastrophic because this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 may happen only in the beginning, when the minor mode kicks in. Typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 @code{M-x viper-mode} will correct the situation. Viper knows about
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 several such minor modes and takes care of them, so that the above trick
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 is usually not necessary. If you find that some minor mode, e.g.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 @code{nasty-mode.el} interferes with Viper, putting the following in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 @file{.vip} should fix the problem:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (vip-harness-minor-mode "nasty-mode")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221 The argument to @code{vip-harness-minor-mode} is the name of the file for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 offending minor mode with the suffixes @file{.el} and @file{.elc} removed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 It may be tricky, however, to find out which minor mode is at fault. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 only guidance here is to look into the file that defines the minor mode you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 are suspecting, say @code{nasty-mode.el}, and see if it has a variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 called @code{nasty-mode-map}. Then check if there is a statement of the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (define-key nasty-mode-map key function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 that binds the misbehaving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 keys. If so, use the above line to harness @code{nasty-mode}. If your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 suspicion is wrong, no harm is done if you harness a minor mode that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 doesn't need to be harnessed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 @vindex @code{vip-want-emacs-keys-in-vi}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 @vindex @code{vip-want-emacs-keys-in-insert}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 @vindex @code{vip-always}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 @findex @code{vip-set-hooks}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 @findex @code{viper-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 @findex @code{vip-harness-minor-mode}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 @findex @code{remove-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 @findex @code{add-hook}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 @node Viper Specials,Vi Macros,Packages that Change Keymaps,Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 @section Viper Specials
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 Viper extends Vi with a number of useful features. This includes various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 search functions, histories of search strings, Ex commands, insertions, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 Vi's destructive commands. In addition, Viper supports file name completion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 and history, completion of Ex commands and variables, and many other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 features. Some of these features are explained in detail elsewhere in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 document. Other features are explained here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257 @item (vip-buffer-search-enable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 @item vip-buffer-search-char nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259 Enable buffer search. Explicit call to @code{vip-buffer-search-enable}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 sets @code{vip-buffer-search-char} to @kbd{g}. Alternatively, the user can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 set @code{vip-buffer-search-char} in @file{.vip} to a key sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 to be used for buffer search. There is no need to call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 @code{vip-buffer-search-enable} in that case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 @findex @code{vip-buffer-search-enable}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 @vindex @code{vip-buffer-search-char}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 @item vip-toggle-search-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 This function, bound to @kbd{C-c /}, lets one toggle case-sensitive and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 case-insensitive search, and also switch between plain vanilla search and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 search via regular expressions. Without the prefix argument, the user is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 asked which mode to toggle. With prefix argument 1, this toggles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 case-sensitivity. With prefix argument 2, regular expression/vanilla search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 will be toggled.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 However, we found that the most convenient way to toggle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 these options is to bind a Vi macro to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 bind @kbd{//} to toggles case sensitivity and to @kbd{///} to toggles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 vanilla search. Thus, quickly hitting @kbd{/} twice will switch Viper from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 case sensitive search to case-insensitive. Repeating this once again will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 restore the original state. Likewise, quickly hitting @kbd{/} three times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 will switch you from vanilla-style search to search via regular expressions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 If you hit something other than @kbd{/} after the first @kbd{/} or if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 second @kbd{/} doesn't follow quickly enough, then Viper will issue the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 usual prompt @kbd{/} and will wait for input, as usual in Vi.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 If you don't like this behavior, you can ``unrecord'' these macros in your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 @file{~/.vip} file. For instance, if u don't like the above feature, put
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 this in @file{~/.vip}:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 (vip-unrecord-kbd-macro "//" 'vi-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 (vip-unrecord-kbd-macro "///" 'vi-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 @findex @code{vip-unrecord-kbd-macro}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 @xref{Vi Macros}, for more information on Vi macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 @item vip-heading-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 @item vip-heading-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 @cindex headings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 @cindex sections
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 @cindex paragraphs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 @cindex sentences
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 Regular Expressions for @kbd{[[} and @kbd{]]}. Note that Emacs defines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 Regexps for paragraphs and sentences. @xref{Paragraphs,,Paragraphs and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 Sentences,emacs,The GNU Emacs Manual}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 @item M-x vip-set-expert-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 @findex @code{vip-set-expert-level}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 Change your user level interactively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 @item vip-smart-suffix-list '("" "tex" "c" "cc" "el" "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 @vindex @code{vip-smart-suffix-list}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 Viper supports Emacs-style file completion when it prompts the user for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 file name. However, in many cases, the same directory may contain files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 with identical prefix but different suffixes, e.g., prog.c, prog.o,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 paper.tex, paper.dvi. In such cases, completion will stop at the `.'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 If the above variable is a list of strings representing suffixes, Viper will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 try these suffixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 in the order listed and will check if the corresponding file exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 For instance, if completion stopped at `paper.' and the user typed RET,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 then Viper will check if the files `paper.', `paper.tex', `paper.c', etc., exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 It will take the first such file. If no file exists, Viper will give a chance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 to complete the file name by typing the appropriate suffix. If `paper.' was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 the intended file name, hitting return will accept it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 To turn this feature off, set the above variable to @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 @item vip-insertion-ring-size 14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 @vindex @code{vip-insertion-ring-size}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 @cindex Insertion ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 Viper remembers what was previously inserted in Insert and Replace states.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 Several such recent insertions are kept in a special ring of strings of size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 @code{vip-insertion-ring-size}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 If you enter Insert or Replace state you can reinsert strings from this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 ring by typing @kbd{C-c M-p} or @kbd{C-c M-n}. The former will search the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 ring in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 the direction of older insertions, and the latter will search in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 the direction of newer insertions. Hitting @kbd{C-c M-p} or @kbd{C-c M-n}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 in succession
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 will undo the previous insertion from the ring and insert the next item on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 the ring. If a larger ring size is needed, change the value of the above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 variable in the @file{~/.vip} file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 Since typing these sequences of keys may be tedious, it is suggested that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 user should bind a function key, such as @kbd{f31}, as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 (define-key vip-insert-global-user-map [f31]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 'vip-insert-prev-from-insertion-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 This binds @kbd{f31} (which is usually @kbd{R11} on a Sun workstation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 to the function that inserts the previous string in the insertion history.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 To rotate the history in the opposite
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 direction, you can either bind an unused key to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 @code{vip-insert-next-from-insertion-ring} or hit any digit (1 to 9) then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 @kbd{f31}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 this will interfere with the Minibuffer histories and, possibly, other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 major modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 @item vip-command-ring-size 14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 @vindex @code{vip-command-ring-size}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 @cindex Destructive command ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 @cindex Destructive command history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 Viper keeps track of the recent history of destructive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 commands, such as @kbd{dw}, @kbd{i}, etc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 In Vi state,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 the most recent command can be re-executed by hitting `@kbd{.}', as in Vi.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 However, repeated typing @kbd{C-c M-p} will cause Viper to show the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 previous destructive commands in the minibuffer. Subsequent hitting `@kbd{.}'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 will execute the command that was displayed last.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 The key @kbd{C-c M-n} will cycle through the command history in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 opposite direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 Since typing @kbd{C-c M-p} may be tedious, it is more convenient to bind an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 appropriate function to an unused function key on the keyboard and use that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 key. For instance, the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 (define-key vip-vi-global-user-map [f31]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 'vip-prev-destructive-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 binds the key @kbd{f31} (which is usually @kbd{R11} on a Sun workstation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 to the function that searches the command history in the direction of older
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 commands. To search in the opposite
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 direction, you can either bind an unused key to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 @code{vip-next-destructive-command} or hit any digit (1 to 9) then @kbd{f31}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 this will interfere with the Minibuffer histories and, possibly, other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 major modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 @item vip-minibuffer-vi-face 'vip-minibuffer-vi-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 @item vip-minibuffer-insert-face 'vip-minibuffer-insert-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 @item vip-minibuffer-emacs-face 'vip-minibuffer-emacs-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 These faces control the appearance of the minibuffer text in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 corresponding Viper states. For heavy-duty customization, consult
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 the Lisp Reference to Emacs. You can also take a look how these faces are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 defined in @file{viper.el}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 However, on a color workstation, the following method usually suffices:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 (set-face-foreground vip-minibuffer-vi-face "blue")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 (set-face-background vip-minibuffer-emacs-face "orchid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 This will make a blue foreground in the Minibuffer when it is in Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 state; its background will turn to orchid when it switches to Emacs state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 Note that only the text you type in is affected by the above faces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 Prompts and Minibuffer messages are not affected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 Purists who do not like adornments in the minibuffer can always zap them by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 putting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 (copy-face 'default 'vip-minibuffer-vi-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 (copy-face 'default 'vip-minibuffer-insert-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 (copy-face 'default 'vip-minibuffer-emacs-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 in the @file{~/.vip} file. However, in that case, the user will not have any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 indication of the current Viper state in the minibuffer. (This is important
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 if the user accidentally switches to another Viper state by typing @kbd{ESC} or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 @kbd{C-z}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 @cindex Multifile documents and programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 Viper provides some support for multi-file documents and programs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 If a document consists of several files we can designate one of them as a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 master and put the following at the end of that file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 ;;; Local Variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 ;;; eval: (vip-setup-master-buffer "file1" "file2" "file3" "file5" "file5")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 ;;; End:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 where @code{file1} to @code{file5} are names of files related to the master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 file. Next time, when the master file is visited, the command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 @code{vip-setup-master-buffer} will be evaluated and the above files will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 be associated with the master file. Then, the new Ex command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 @kbd{:RelatedFile} (abbr. @kbd{:R}) will display files 1 to 5 one after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 another, so you can edit them. If a file is not in any Emacs buffer, it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 will be visited. The command @kbd{PreviousRelatedFile} (abbr., @kbd{:P})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 goes through the file list in the opposite direction.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 @findex @kbd{:RelatedFile}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 @findex @kbd{:PreviousRelatedFile}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 These commands are akin to @kbd{:n} and @kbd{:N}, but they allow the user to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 focus on relevant files only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 Note that only the master file needs to have the aforementioned block of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 commands. Also, ";;;" above can be replaced by some other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 markers. Semicolon is good for Lisp programs, since it is considered a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 comment designator there. For LaTeX, this could be "%%%", and for C the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 above block should be commented out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 Even though these commands are sometimes useful, they are no substitute for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 the powerful @emph{tag table} facility of Emacs. Viper's @kbd{:tag} command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 in a primitive interface to Emacs tags. @xref{Tags,Tags,Tags,emacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 The Gnu Emacs Manual}, for more information on tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 The following two commands are normally bound to a mouse click and are part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 of Viper. They work only if Emacs runs as an application under X
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 Windows (or under some other window system for which a port of GNU Emacs 19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 is available). Clicking the mouse when Emacs is invoked in an Xterm window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 (using @code{emacs -nw}) will do no good.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 @table @code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 @cindex mouse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 @item M-S-mouse-1 (Emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 @item meta shift button1up (XEmacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 Holding Meta and Shift while clicking mouse button 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 will initiate search for a region under the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 mouse pointer (defined below). This command can take a prefix argument,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 which indicates the occurrence of the pattern to search for.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 Note: Viper binds this mouse action only if it is not already bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 something else. If you want to use this feature and @kbd{M-S-mouse-1}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 is already used for something else, you can rebind mouse-search as, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 example, in the following example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (global-set-key [M-mouse-1] 'vip-mouse-click-search-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 (global-set-key [M-down-mouse-1] 'vip-mouse-catch-frame-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 This would bind mouse search to the action invoked by pressing the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 Meta key and clicking mouse button 1. Note: if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 @code{vip-mouse-click-search-word} is bound to an action, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 @code{vip-mouse-catch-frame-switch} must be bound to a down-action, as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 shown in the above example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 In XEmacs, you can change bindings as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 (global-set-key [(meta control button1up)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 'vip-mouse-click-search-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 (global-set-key [(meta control button1)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 'vip-mouse-catch-frame-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 if, say, you prefer to hold both meta and control while clicking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 Like in Emacs, there are special rules for binding these functions: the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 first must be bound to a button-up event while the second must be bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 a button-event (which is XEmacs' equivalent of a down-mouse event). Also,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 in Emacs, the double-click and triple-click actions for the same button
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 (@code{double-S-mouse-1}, etc., if the above default binding is used)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 should not be bound (or it should be bound to the same function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 @code{vip-mouse-click-search-word}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 The region that is chosen as a pattern to search for is determined as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 follows. If search is invoked via a single click, Viper chooses the region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 that lies between the beginning of the ``word'' under the pointer (``word''
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 is understood in Vi sense) and the end of that word. The only difference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 with Vi's words is that in Lisp major modes `-' is considered an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 alphanumeric symbol. This is done for the convenience of working with Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 symbols, which often have an `-' in them. Also, if you click on a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 non-alphanumeric character that is not a word separator (in Vi sense) then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 this character will also be considered alphanumeric, provided that it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 adjacent (from either side) to an alphanumeric character. This useful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 feature gives added control over the patterns selected by the mouse click.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 On a double-click, the region is determined by the beginning of the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 Vi's ``Word'' (i.e., the largest non-separator chunk of text) and the End
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 of that ``Word'' (as determined by the @kbd{E} command).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 On a triple-click, the region consists of the entire line where the click
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 occurred with all leading and trailing spaces and tabs removed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 @item M-S-mouse-2 (Emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 @item meta shift button2up (XEmacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 Holding Meta and Shift while clicking mouse button 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 will insert the region surrounding the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 mouse pointer. The rules defining this region are the same as for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 mouse-search. This command takes an optional prefix argument, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 indicates how many such regions to snarf from the buffer and insert. (In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 case of a triple-click, the prefix argument is ignored.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 Note: Viper binds this mouse action only if it not already bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 something else. If you want to use this feature and @kbd{S-mouse-2}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 is already used for something else, you can rebind mouse-insert as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 (global-set-key [M-mouse-2] 'vip-mouse-click-insert-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 (global-set-key [M-down-mouse-2] 'vip-mouse-catch-frame-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 In XEmacs, you can change the bindings as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 @lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 (global-set-key [(meta control button2up)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 'vip-mouse-click-insert-word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 (global-set-key [(meta control button2)]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 'vip-mouse-catch-frame-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 @end lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 @item vip-multiclick-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 This variable controls the rate at which double-clicking must occur for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 purpose of mouse search and mouse insert. By default, this is set to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 @code{double-click-time} in Emacs and to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 @code{mouse-track-multi-click-time} milliseconds in XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 @end table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 @kindex @kbd{S-mouse-1}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 @kindex @kbd{S-mouse-2}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 @kindex @kbd{meta shift button1up}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 @kindex @kbd{meta shift button2up}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 @vindex @code{vip-multiclick-timeout}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 @findex @code{vip-mouse-click-insert-word}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 @findex @code{vip-mouse-click-search-word}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 Note: The above functions search and insert in the selected window of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 the latest active frame. This means that you can click in another window or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 another frame and have search or insertion done in the frame and window you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 just left. This lets one use these functions in a multi-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 configuration. However, this may require some getting used to. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 instance, if you are typing in a frame, A, and then move the mouse to frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 B and click to invoke mouse search, search (or insertion) will be performed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 in frame A. To perform search/insertion in frame B, you will first have to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 shift focus there, which doesn't happen until you type a character or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 perform some other action in frame B---mouse search doesn't shift focus (in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 XEmacs, to shift focus to frame B, you will have to select this frame with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 a mouse, by clicking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 If you decide that you don't like the above feature and always want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 search/insertion be performed in the frame where the click occurs, don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 bind (and unbind, if necessary) @code{vip-mouse-catch-frame-switch} from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 the mouse event it is bound to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 Mouse search is integrated with Vi-style search, so you can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 repeat it with @kbd{n} and @kbd{N}. It should be also noted that, while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 case-sensitivity of search in Viper is controlled by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 @code{vip-case-fold-search}, the case of mouse search is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 controlled by the Emacs variable @code{case-fold-search}, which may be set
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 differently from @code{vip-case-fold-search}. Therefore, case-sensitivity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 of mouse search may be different from that of the usual Vi-style search.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 Finally, if the way Viper determines the word to be searched for or to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 inserted is not what you want, there is a variable,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 @code{vip-surrounding-word-function}, which can be changed to indicate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 another function for snarfing words out of the buffer. The catch is that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 you will then have to write such a function and make it known to your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 Emacs. The function @code{vip-surrounding-word} in @file{viper.el} can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 used as a guiding example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 @node Vi Macros, ,Viper Specials,Customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 @section Vi Macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 @cindex Vi macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 Viper supports much enhanced Vi-style macros and also facilitates the use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 of Emacs-style macros. To define a temporary macro, it is generally more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 convenient to use Emacs keyboard macro facility. Emacs keyboard macros are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 usually defined anonymously, and the latest macro can be executed by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 @kbd{C-x e} (or @kbd{*}, if Viper is in Vi state). If you need to use several
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 temporary macros, Viper lets you save them to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 register (a lowercase letter); such macros can then be executed by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 @kbd{@@a} in Vi state (if a macro was previously saved in register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 @kbd{a}).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 @xref{Macros and Registers}, for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 If, however, you need to use a macro regularly, it must be given a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 permanent name and saved. Emacs manual explains how to do this, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2610 invocation of named Emacs macros is quite different from Vi's. First,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2611 invocation of permanent Emacs macros takes time because of the extra keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2612 Second, binding such macros to function keys, for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 fast access, hogs valuable real estate on the keyboard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 Vi-style macros are better in that respect, since Vi lets the user overload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 the meaning of key sequences: keys typed in fast succession are treated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 specially, if this key sequence is bound to a macro.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 Viper provides keyboard macros through the usual Ex commands, @kbd{:map} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 @kbd{:map!}. Vi-style macros are much more powerful in Viper than
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 they are in the original Vi and in other emulators. This is because Viper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 implements an enhanced vi-style
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 interface to the powerful Emacs keyboard macro facility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 First, any Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 command can be executed while defining a macro, not just the Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 commands. In particular, the user can invoke Emacs commands via @kbd{M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 command-name} or by pressing various function keys on the keyboard. One
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 can even use the mouse, although this is usually not useful and is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 recommended (and macros defined with the use of the mouse cannot be saved in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 command history and in the startup file, for future use).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 Macros defined by mixing Vi and Emacs commands are represented as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 vectors. So, don't be confused when you see one (usually through the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 history of Ex commands). For instance, if @kbd{gg} is defined by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 @kbd{l}, the up-arrow key and @kbd{M-x next-line}, its definition will look
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 as follows in Emacs (in XEmacs, it looks slightly different, see below):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 [l up (meta x) n e x t - l i n e return]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 Second, Viper macros are defined in a WYSIWYG style. This means that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 commands are executed as you type them, so you can see precisely what is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 being defined. Third, macros can be bound to arbitrary sequences of keys,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 not just to printable keys. For instance, one can define a macro that will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 be invoked by hitting @kbd{f3} then @kbd{f2} function keys. (The keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 @kbd{delete} and @kbd{backspace} are excluded; also, a macro invocation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 sequence can't start with ESC. Some other keys, such as @kbd{f1} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 @kbd{help}, can't be bound to macros under Emacs (not XEmacs), since they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 are bound in @code{key-translation-map}, which overrides any other binding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 the user gives to keys. In general, keys that have a binding in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 @code{key-translation-map} can't be bound to a macro.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 Fourth, in Viper, one can define macros that are specific to a given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 buffer, a given major mode, or macros that are defined for all buffers. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 fact, the same macro name can have several different definitions: one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 global, several definitions for various major modes, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 definitions for various specific buffers. Buffer-specific definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 override mode-specific definitions, which, in turn, override global
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 As if all that is not enough, Viper (through its interface to Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 macros) lets the user define keyboard macros that ask for confirmation or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 even prompt the user for input and then continue. To do this, one should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 type @kbd{C-x q} (for confirmation) or @kbd{C-u C-x q} (for prompt).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 For details, @pxref{Kbd Macro Query,,Customization,emacs,The GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 Manual} @refill
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 When the user finishes defining a macro (which is done by typing @kbd{C-x)} ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 a departure from Vi), you will be asked whether you want this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 macro to be global, mode-specific, or buffer-specific. You will also be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 given a chance to save the macro in your @file{~/.vip} file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 This is the easiest way to save a macro and make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 it permanently available. If you work your startup files with bare hands,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 here is how Viper saves the above macro so that it will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 available in Viper's Insert state (and Replace state) in buffer @code{my-buf}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 only:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 (vip-record-kbd-macro "gg" 'insert-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 [l up (meta x) n e x t - l i n e return]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 "my-buf")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 To do the same for Vi state and all buffers with the major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 @code{cc-mode}, use:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 (vip-record-kbd-macro "gg" 'vi-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 [l up (meta x) n e x t - l i n e return]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 'cc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 Both macro names and macro definitions are vectors of symbols that denote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 keys on the keyboard. Some keys, like @kbd{\}, @kbd{ }, or digit-keys must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 be escaped with a backslash. Modified keys are represented as lists. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 instance, holding Meta and Control and pressing @kbd{f4} is represented as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 @kbd{(control meta f4)}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 If all members of a vectors are printable characters (or sequences, such as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 @kbd{\e}, @kbd{\t}, for ESC and TAB), then they can also be represented as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 strings:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 (vip-record-kbd-macro "aa" 'vi-state "aaa\e" "my-buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 Thus, typing @kbd{aa} fast in Vi state will switch Viper to Insert state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 (due to the first @kbd{a}), insert @kbd{aa}, and then it will switch back to Vi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 state. All this will take effect only in the buffer named @code{my-buffer}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 Note that the last argument to @code{vip-record-kbd-macro} must be either a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 string (a buffer name), a symbol representing a major mode, or @code{t};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 the latter says that the macro is to be defined for all buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 (which is how macros are defined in original Vi).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 For convenience, Viper also lets you define Vi-style macros in its Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 state. There is no Ex command, like @kbd{:map} and @kbd{:map!} for doing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 this, but the user can include such a macro in the @file{~/.vip} file. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 only thing is that the @code{vip-record-kbd-macro} command should specify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 @code{'emacs-state} instead of @code{'vi-state} or @code{'insert-state}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 The user can get rid of a macro either by using the Ex commands @kbd{:unmap}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 and @kbd{:unmap!} or by issuing a call to @code{vip-unrecord-kbd-macro}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 The latter is more powerful, since it can delete macros even in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 @code{'emacs-state}. However, @code{vip-unrecord-kbd-macro} is usually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 needed only when the user needs to get rid of the macros that are already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 predefined in Viper.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 The syntax is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 @findex @code{vip-unrecord-kbd-macro}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2735 (vip-unrecord-kbd-macro macro state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 The second argument must be @code{'vi-state}, @code{'insert-state}, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 @code{'emacs-state}. The first argument is a name of a macro. To avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 mistakes in specifying names of existing macros, type @kbd{M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 vip-describe-kbd-macros} and use a name from the list displayed by this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 If an error occurs during macro definition, Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 aborts the process, and it must be repeated. This is analogous to Vi,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 except that in Vi the user doesn't know there is an error until the macro is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 actually run. All that means that in order for a definition to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 successful, the user must do some simple planning of the process in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 advance, to avoid errors. For instance, if you want to map @kbd{gg} to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 @kbd{llll} in Vi state, you must make sure that there is enough room on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 current line. Since @kbd{l} moves the cursor forward, it may signal an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 error on reaching the end of line, which will abort the definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 These precautions are necessary only when defining macros; they will help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 avoid the need to redo the job. When macros are actually run, an error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 during the execution will simply terminate the current execution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 (but the macro will remain mapped).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 A macro name can be a string of characters or a vector of keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 The latter makes it possible to define macros bound to, say, double-hits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 on a function key, such as @kbd{up} or @kbd{f13}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 This is very useful if you run out of function keys on your keyboard; it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 makes Viper macro facility a @emph{keyboard doubler}, so to speak.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 Elsewhere (@xref{Keybindings}, for details), we review
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 the standard Emacs mechanism for binding function keys to commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 For instance,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 (global-set-key [f13] 'repeat-complex-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 @noindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 binds the key f13 to the Emacs function that repeats the last minibuffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 command. Under Viper, however, you may still use this key for additional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 purposes, if you bind, say, a double-hitting action for that key to some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 other function. Emacs doesn't allow the user to do that, but Viper does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 this through its keyboard macro facility. To do this, type @kbd{:map }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 first. When you are asked to enter a macro name, hit f13 twice, followed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 RET or SPC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 Emacs will now start the mapping process by actually executing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 Vi and Emacs commands, so that you could see what will happen each time the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 macro is executed. Suppose now we wanted to bind the key sequence
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 @kbd{f13 f13} to the command @code{eval-last-sexp}. To accomplish this, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 can type @kbd{M-x eval-last-sexp} followed by @kbd{C-x )}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 If you answer positively to Viper's offer to save this macro in @file{~/.vip}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 for future uses, the following will be inserted in that file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 (vip-record-kbd-macro [f16 f16] 'vi-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 [(meta x) e v a l - l a s t - s e x p]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 'lisp-interaction-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 To illustrate the above point, Viper provides two canned macros, which, by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 default, are bound to @kbd{[f12 \1]} and @kbd{[f12 \2]} (invoked by typing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 @kbd{f12} then @kbd{1} and @kbd{2}, respectively). These macros are useful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 shortcuts to Viper's command ring history. The first macro will execute the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 second-last destructive command (the last one is executed by @kbd{.}, as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 usual). The second macro executes the third-last command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 If you need to go deeper into the command history, you will have to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 other commands, as described earlier in this section; or you can bind,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 say, @kbd{f12 \3} like this:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 (vip-record-kbd-macro [f12 \3] 'vi-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 [(meta x) r e p e a t - f r o m - h i s t o r y]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 Note that even though the macro uses the function key @kbd{f12}, the key is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 actually free and can still be bound to some Emacs function via
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 @code{define-key} or @code{global-set-key}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 Viper allows the user to define macro names that are prefixes of other macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 For instance, one can define @kbd{[[} and @kbd{[[[[} to be macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 If you type the exact sequence of such keys and then pause, Viper will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 execute the right macro. However, if you don't pause and, say, type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 @kbd{[[[[text} then the conflict is resolved as follows. If only one of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 key sequences, @kbd{[[} or @kbd{[[[[} has a definition applicable to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 current buffer, then, in fact, there is no conflict and the right macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 will be chosen. If both have applicable definitions, then the first one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 found will be executed. Usually this is the macro with a shorter name. So,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 in our case, @kbd{[[[[text} will cause the macro @kbd{[[} to be executed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 twice and then the remaining keys, @kbd{t e x t}, will be processed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 When defining macros using @kbd{:map} or @kbd{:map!}, the user enters the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 actually keys to be used to invoke the macro. For instance, you should hit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 the actual key @kbd{f6} if it is to be part of a macro name; you do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 @emph{not} write `f 6'. When entering keys, Viper displays them as strings or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 vectors (e.g., "abc" or [f6 f7 a]). The same holds for unmapping. Hitting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 TAB while typing a macro name in the @kbd{:unmap} or @kbd{:unmap!} command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 will cause name completion. Completions are displayed as strings or vectors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 However, as before, you don't actually type ``"'', ``['', or ``]'' that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 appear in the completions. These are meta-symbols that indicate whether
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 the corresponding macro name is a vector or a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 One last difference from Vi: Vi-style keyboard macros cannot be defined in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 terms of other Vi-style keyboard macros (but named Emacs macros are OK).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2844 More precisely, while defining or executing a macro, the special meaning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 of key sequences (as Vi macros) is ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 This is because it is all too easy to create an infinite loop in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 Since Viper macros are much more powerful than Vi's it is impossible to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848 detect such loops. In practice, this is not really a limitation but,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 rather, a feature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 We should also note that Vi macros are disabled in the Minibuffer, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 helps keep some potential troubles away.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2854 The rate at which the user must type keys in order for them to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2855 recognized as a timeout macro is controlled by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 @code{vip-fast-keyseq-timeout}, which defaults to 200 milliseconds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2857 @vindex @code{vip-fast-keyseq-timeout}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2859 For the most part, Viper macros defined in @file{~/.vip} can be shared
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2860 between Emacs, XEmacs, and X and TTY modes. However, macros defined via
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 function keys may need separate definitions when XEmacs and Emacs have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 different names for the same keyboard key. For instance, the `Page Up' key
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2863 may be known in Emacs as @kbd{prior} and in XEmacs as @kbd{pgup}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2864 The problem with TTY may be that the function keys there generate sequences
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2865 of events instead of a single event (as under a window system).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2866 Both Emacs and XEmacs mape some of these sequences back to the logical keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2867 (e.g., the sequences generated by the arrow keys are mapped to @kbd{up},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2868 @kbd{left}, etc.). However, not all function keys are mapped in this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2869 Macros that are bound to key sequences that contain such unmapped function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2870 keys have to be redefined for TTY's (and possibly for every type of TTY you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2871 may be using). To do this, start Emacs on an appropriate TTY device and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2872 define the macro using @kbd{:map}, as usual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2874 @findex @code{vip-describe-kbd-macros}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2875 Finally, Viper provides a function that conveniently displays all macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 currently defined. To see all macros along with their definitions, type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 @kbd{M-x vip-describe-kbd-macros}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2878
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 @include viper-cmd.texi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 @node Acknowledgments,,,Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 @unnumbered Acknowledgments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 Viper, formerly known as VIP-19, was written by Michael Kifer. Viper is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 based on the original VIP package by Masahiko Sato and on its enhancement,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 VIP 4.4, by Aamod Sane. This manual is an adaptation of the manual for VIP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2888 4.4, which, in turn, was based on Sato's manual for VIP 3.5.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2890 Many contributors on the net pointed out bugs and suggested a number of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2891 useful features. Here is a (hopefully) complete list of contributors:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 jjm@@hplb.hpl.hp.com (Jean-Jacques Moreau), jl@@cse.ogi.edu (John
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 Launchbury), rxga@@ulysses.att.com, jamesm@@bga.com (D.J. Miller II),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 ascott@@fws214.intel.com (Andy Scott), toma@@convex.convex.com,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 dave@@hellgate.utah.edu, cook@@biostat.wisc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 (Tom Cook), lindstro@@biostat.wisc.edu (Mary Lindstrom),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 edmonds@@edmonds.home.cs.ubc.ca (Brian Edmonds), mveiga@@dit.upm.es
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 (Marcelino Veiga Tuimil), dwight@@toolucky.llnl.gov (Dwight Shih),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 phil_brooks@@MENTORG.COM (Phil Brooks), kin@@isi.com (Kin Cho),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 ahg@@panix.com (Al Gelders), dwallach@@cs.princeton.edu (Dan Wallach),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 hpz@@ibmhpz.aug.ipp-garching.mpg.de (Hans-Peter Zehrfeld),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 simonb@@prl.philips.co.uk (Simon Blanchard), Mark.Bordas@@East.Sun.COM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 (Mark Bordas), gviswana@@cs.wisc.edu (Guhan Viswanathan),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 meyering@@comco.com (Jim Meyering), pfister@@cs.sunysb.edu (Hanspeter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 Pfister), amade@@diagram.fr (Paul-Bernard Amade),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 jackr@@dblues.engr.sgi.com (Jack Repenning),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 pogrell@@informatik.hu-berlin.de (Lutz Pogrell),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 csdayton@@midway.uchicago.edu (Soren Dayton),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 pradyut@@cs.uchicago.edu (Pradyut Shah),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 vrenjak@@sun1.racal.com (Milan Vrenjak),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 gvr@@halcyon.com (George V. Reilly),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 whicken@@dragon.parasoft.com (Wendell Hicken),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 terra@@diku.dk (Morten Welinder),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 kanze@@gabi-soft.fr (James Kanze),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 hatazaki@@bach.convex.com (Takao Hatazaki),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 sawdey@@lcse.umn.edu (Aaron Sawdey),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 jobrien@@hchp.org (John O'Brien),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 mrb@@Eng.Sun.COM (Martin Buchholz)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 @node Key Index,Function Index,,Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 @unnumbered Key Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 @printindex ky
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 @node Function Index,Variable Index,Key Index,Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 @unnumbered Function Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 @printindex fn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 @node Variable Index,Package Index,Function Index,Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 @unnumbered Variable Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2940 @printindex vr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 @node Package Index,Concept Index,Variable Index,Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 @unnumbered Package Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 @printindex pg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 @node Concept Index,,Package Index,Top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 @comment node-name, next, previous, up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 @unnumbered Concept Index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 @printindex cp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 @contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 @bye