Mercurial > hg > xemacs-beta
comparison man/viper.texi @ 163:0132846995bd r20-3b8
Import from CVS: tag r20-3b8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:43:35 +0200 |
parents | 43dd3413c7c7 |
children | 2d532a89d707 |
comparison
equal
deleted
inserted
replaced
162:4de2936b4e77 | 163:0132846995bd |
---|---|
2 | 2 |
3 % | 3 % |
4 \input texinfo | 4 \input texinfo |
5 | 5 |
6 @comment Using viper.info instead of viper in setfilename breaks DOS. | 6 @comment Using viper.info instead of viper in setfilename breaks DOS. |
7 @setfilename viper | 7 @comment @setfilename viper |
8 @comment @setfilename ../info/viper | |
9 @comment @setfilename viper.info | 8 @comment @setfilename viper.info |
9 @setfilename ../info/viper | |
10 | 10 |
11 @iftex | 11 @iftex |
12 @finalout | 12 @finalout |
13 @end iftex | 13 @end iftex |
14 | 14 |
15 @titlepage | 15 @titlepage |
16 @title Viper Is a Package for Emacs Rebels | 16 @title Viper Is a Package for Emacs Rebels |
17 @subtitle a Vi emulator for GNU Emacs 19 and XEmacs 19 | 17 @subtitle a Vi emulator for GNU Emacs 19 and XEmacs 19 |
18 @subtitle May 1997, Viper Version 2.93 | 18 @subtitle June 1997, Viper Version 2.94 |
19 | 19 |
20 @author Masahiko Sato (VIP 3.5) | 20 @author Masahiko Sato (VIP 3.5) |
21 @author Aamod Sane (VIP 4.4) | 21 @author Aamod Sane (VIP 4.4) |
22 @author Michael Kifer (Viper) | 22 @author Michael Kifer (Viper) |
23 | 23 |
144 It is recommended that you read the chapter Overview. The other chapters | 144 It is recommended that you read the chapter Overview. The other chapters |
145 will be useful for customization and advanced usage. | 145 will be useful for customization and advanced usage. |
146 | 146 |
147 You should also learn to use the Info on-line hypertext manual system that | 147 You should also learn to use the Info on-line hypertext manual system that |
148 comes with Emacs. This manual can be read as an Info file. Try the command | 148 comes with Emacs. This manual can be read as an Info file. Try the command |
149 @kbd{ESC x info} with vanilla Emacs sometime. | 149 @kbd{@key{ESC} x info} with vanilla Emacs sometime. |
150 | 150 |
151 Comments and bug reports are welcome. | 151 Comments and bug reports are welcome. |
152 @code{kifer@@cs.sunysb.edu} is the current address for Viper bug reports. | 152 @code{kifer@@cs.sunysb.edu} is the current address for Viper bug reports. |
153 Please use the Ex command @kbd{:submitReport} for this purpose.@refill | 153 Please use the Ex command @kbd{:submitReport} for this purpose.@refill |
154 | 154 |
286 and M, e.g. @kbd{^Z} as @kbd{C-z} and @kbd{Meta-x} as @kbd{M-x}. | 286 and M, e.g. @kbd{^Z} as @kbd{C-z} and @kbd{Meta-x} as @kbd{M-x}. |
287 The Meta key is usually located on each side of the Space bar; it is used | 287 The Meta key is usually located on each side of the Space bar; it is used |
288 in a manner similar to the Control key, e.g., @kbd{M-x} means typing | 288 in a manner similar to the Control key, e.g., @kbd{M-x} means typing |
289 @kbd{x} while holding the Meta key down. | 289 @kbd{x} while holding the Meta key down. |
290 For keyboards that do not have a Meta key, @key{ESC} is used as Meta. | 290 For keyboards that do not have a Meta key, @key{ESC} is used as Meta. |
291 Thus @kbd{M-x} is typed as @kbd{ESC x}. Viper uses @key{ESC} to switch | 291 Thus @kbd{M-x} is typed as @kbd{@key{ESC} x}. Viper uses @key{ESC} to switch |
292 from Insert state to Vi state. Therefore Viper defines @kbd{C-\} as its Meta | 292 from Insert state to Vi state. Therefore Viper defines @kbd{C-\} as its Meta |
293 key in Vi state. @xref{Vi State}, for more info.@refill | 293 key in Vi state. @xref{Vi State}, for more info.@refill |
294 | 294 |
295 Emacs is structured as a lisp interpreter around a C core. Emacs keys | 295 Emacs is structured as a lisp interpreter around a C core. Emacs keys |
296 cause lisp functions to be called. It is possible to call these | 296 cause lisp functions to be called. It is possible to call these |
297 functions directly, by typing @kbd{M-x function-name}. | 297 functions directly, by typing @kbd{M-x function-name}. |
298 | 298 |
299 @node Loading Viper, States in Viper, Emacs Preliminaries, Overview | 299 @node Loading Viper, States in Viper, Emacs Preliminaries, Overview |
300 @section Loading Viper | 300 @section Loading Viper |
301 | 301 |
302 First, make sure that all six Viper files @file{viper*.el} are somewhere on | 302 The most common way to load it automatically is to include the lines (in |
303 Emacs @dfn{load path}. The load path is a list of directories where Emacs | 303 the given order!): |
304 looks for its Lisp code; it is similar to Unix environment variable | 304 |
305 @var{PATH}. The load path is determined by the Lisp variable | |
306 @code{load-path}. | |
307 | |
308 Type @code{C-h v load-path RET} to check the current load path of your | |
309 Emacs. (Here and later, @kbd{RET} stands for carriage return.) If the files | |
310 @file{viper*.el} are not in any directory on the load path, you should | |
311 create your own directory and put it on the load path; then put | |
312 @file{viper*.el} in that directory. To put a new directory, say | |
313 @file{~/emacslib}, on your load path, add the following line at the | |
314 beginning of your @file{~/.emacs} file: | |
315 @lisp | 305 @lisp |
316 (setq load-path (cons "~/emacslib" load-path)) | 306 (setq viper-mode t) |
317 @end lisp | |
318 It is recommended that you compile @file{viper.el} by running | |
319 @example | |
320 make all | |
321 @end example | |
322 in the directory where Viper was unpacked. The best way to ensure that | |
323 Viper is installed properly is to run | |
324 @example | |
325 make install | |
326 @end example | |
327 in the directory where Viper was unpacked. See README in the Viper | |
328 distribution for the details on which modifications to the make file may be | |
329 necessary. | |
330 | |
331 Once Viper is settled on the load path, | |
332 the most common way to load it automatically is to include the line: | |
333 | |
334 @lisp | |
335 (require 'viper) | 307 (require 'viper) |
336 @end lisp | 308 @end lisp |
337 | 309 |
338 @noindent | 310 @noindent |
339 in your @file{~/.emacs} file. The @file{.emacs} file is placed in your home | 311 in your @file{~/.emacs} file. The @file{.emacs} file is placed in your |
340 directory and it will be executed every time you invoke Emacs. | 312 home directory and it is be executed every time you invoke Emacs. Viper |
341 Viper also uses the file @file{~/.vip} for Viper-specific customization. | 313 also uses the file @file{~/.viper} for Viper-specific customization. If you |
342 If you wish | 314 wish to be in Vi command state whenever this is deemed appropriate by the |
343 to be in Vi command state whenever this is appropriate, you can include the | 315 author, you can include the following line in your @file{.viper}: |
344 following | |
345 line in your @file{.vip}: | |
346 @lisp | 316 @lisp |
347 (setq vip-always t) | 317 (setq viper-always t) |
348 @end lisp | 318 @end lisp |
349 @noindent | 319 @noindent |
350 (@xref{Vi State}, for the explanation of Vi mode.) | 320 (@xref{Vi State}, for the explanation of Vi command state.) |
351 | 321 |
352 Once invoked, Viper will arrange to bring up Emacs buffers in Vi state | 322 Once invoked, Viper will arrange to bring up Emacs buffers in Vi state |
353 whenever this makes sense. | 323 whenever this makes sense. |
354 @xref{Packages that Change Keymaps}, to find out when forcing Vi command state | 324 @xref{Packages that Change Keymaps}, to find out when forcing Vi command state |
355 on a buffer may be counter-productive. | 325 on a buffer may be counter-productive. |
356 | 326 |
357 Even if your @file{.emacs} and @file{.vip} files do not contain any of the | 327 Even if your @file{.emacs} and @file{.viper} files do not contain any of the |
358 above lines, you can still load Viper and enter Vi state by typing the | 328 above lines, you can still load Viper and enter Vi command state by typing the |
359 following from within Emacs: | 329 following from within Emacs: |
360 | 330 |
361 @lisp | 331 @lisp |
362 M-x load-library RET viper RET | |
363 M-x viper-mode | 332 M-x viper-mode |
364 @end lisp | 333 @end lisp |
365 | |
366 @noindent | |
367 Ask your local Emacs administrator if this fails to work. | |
368 | 334 |
369 When Emacs first comes up, if you have not specified a file on the | 335 When Emacs first comes up, if you have not specified a file on the |
370 command line, it will show the @samp{*scratch*} buffer, in the | 336 command line, it will show the @samp{*scratch*} buffer, in the |
371 @samp{Lisp Interaction} mode. After you invoke Viper, you can start | 337 @samp{Lisp Interaction} mode. After you invoke Viper, you can start |
372 editing files by using @kbd{:e}, @kbd{:vi}, or @kbd{v} commands. | 338 editing files by using @kbd{:e}, @kbd{:vi}, or @kbd{v} commands. |
376 | 342 |
377 @node States in Viper, The Minibuffer, Loading Viper,Overview | 343 @node States in Viper, The Minibuffer, Loading Viper,Overview |
378 @section States in Viper | 344 @section States in Viper |
379 | 345 |
380 @kindex @kbd{C-z} | 346 @kindex @kbd{C-z} |
381 @kindex @kbd{ESC} | 347 @kindex @key{ESC} |
382 @kindex @kbd{i} | 348 @kindex @kbd{i} |
383 @cindex Emacs state | 349 @cindex Emacs state |
384 @cindex Vi state | 350 @cindex Vi state |
385 @cindex Insert state | 351 @cindex Insert state |
386 @cindex Replace state | 352 @cindex Replace state |
388 | 354 |
389 Viper has four states, Emacs, Vi, Insert, and Replace. | 355 Viper has four states, Emacs, Vi, Insert, and Replace. |
390 | 356 |
391 @table @samp | 357 @table @samp |
392 @item Emacs state | 358 @item Emacs state |
393 This is the mode plain vanilla Emacs is normally in. After you have loaded | 359 This is the state plain vanilla Emacs is normally in. After you have loaded |
394 Viper, @kbd{C-z} will normally take you to Vi command state. Another | 360 Viper, @kbd{C-z} will normally take you to Vi command state. Another |
395 @kbd{C-z} will take you back to Emacs state. This toggle key can be | 361 @kbd{C-z} will take you back to Emacs state. This toggle key can be |
396 changed, @pxref{Customization} You can also type @kbd{M-x viper-mode} to | 362 changed, @pxref{Customization} You can also type @kbd{M-x viper-mode} to |
397 change to Vi state.@refill | 363 change to Vi state.@refill |
398 | 364 |
405 @item Vi state | 371 @item Vi state |
406 This is the Vi command mode. Any of the Vi commands, such as @kbd{i, o, a}, | 372 This is the Vi command mode. Any of the Vi commands, such as @kbd{i, o, a}, |
407 @dots{}, will take you to Insert state. All Vi commands may | 373 @dots{}, will take you to Insert state. All Vi commands may |
408 be used in this mode. Most Ex commands can also be used. | 374 be used in this mode. Most Ex commands can also be used. |
409 For a full list of Ex commands supported by Viper, type | 375 For a full list of Ex commands supported by Viper, type |
410 @kbd{:} and then @kbd{TAB}. To get help on any issue, including the Ex | 376 @kbd{:} and then @key{TAB}. To get help on any issue, including the Ex |
411 commands, type @kbd{:help}. This will invoke Viper Info | 377 commands, type @kbd{:help}. This will invoke Viper Info |
412 (if it is installed). Then typing @kbd{i} will prompt you for a topic to | 378 (if it is installed). Then typing @kbd{i} will prompt you for a topic to |
413 search in the index. Note, to search for Ex commands in the index, you | 379 search in the index. Note, to search for Ex commands in the index, you |
414 should start them with a ``@kbd{:}'', e.g., @kbd{:WW}. | 380 should start them with a ``@kbd{:}'', e.g., @kbd{:WW}. |
415 | 381 |
416 @item Insert state | 382 @item Insert state |
417 Insert state is the Vi insertion mode. @kbd{ESC} will take you back to | 383 Insert state is the Vi insertion mode. @key{ESC} will take you back to |
418 Vi state. Insert state editing can be done, including auto-indentation. By | 384 Vi state. Insert state editing can be done, including auto-indentation. By |
419 default, Viper disables Emacs keybindings in Insert state. | 385 default, Viper disables Emacs keybindings in Insert state. |
420 | 386 |
421 @item Replace state | 387 @item Replace state |
422 Commands like @kbd{cw} invoke the Replace state. When you cross the | 388 Commands like @kbd{cw} invoke the Replace state. When you cross the |
423 boundary of a replacement region (usually designated via a @samp{$} sign), | 389 boundary of a replacement region (usually designated via a @samp{$} sign), |
424 it will automatically change to Insert state. You do not have to worry | 390 it will automatically change to Insert state. You do not have to worry |
425 about it. The key bindings remain practically the same as in Insert | 391 about it. The key bindings remain practically the same as in Insert |
426 state. If you type ESC, Viper will switch to Vi command mode, terminating the | 392 state. If you type @key{ESC}, Viper will switch to Vi command mode, terminating the |
427 replacement state. @refill | 393 replacement state. @refill |
428 @end table | 394 @end table |
429 | 395 |
430 @cindex mode line | 396 @cindex mode line |
431 | 397 |
545 @refill | 511 @refill |
546 @item C-\ | 512 @item C-\ |
547 @kindex @kbd{C-\} | 513 @kindex @kbd{C-\} |
548 @cindex Meta key | 514 @cindex Meta key |
549 | 515 |
550 Viper uses @kbd{ESC} as a switch between Insert and Vi states. Emacs uses | 516 Viper uses @key{ESC} as a switch between Insert and Vi states. Emacs uses |
551 @kbd{ESC} for Meta. We need a Meta key to call the Meta key functions | 517 @key{ESC} for Meta. We need a Meta key to call the Meta key functions |
552 such as @kbd{M-x function name}. This role is played by the key @kbd{C-\}. | 518 such as @kbd{M-x function name}. This role is played by the key @kbd{C-\}. |
553 Thus, to | 519 Thus, to |
554 get @kbd{M-x}, you should type @kbd{C-\ x} (if the keyboard has no Meta key). | 520 get @kbd{M-x}, you should type @kbd{C-\ x} (if the keyboard has no Meta key). |
555 This works both in the Vi state and the Insert state. | 521 This works both in the Vi state and the Insert state. |
556 Alternatively, you can use @kbd{\ ESC} in Vi state to simulate the meta | 522 Alternatively, you can use @kbd{\ @key{ESC}} in Vi state to simulate the meta |
557 key. | 523 key. |
558 It is possible to use @kbd{ESC} as Meta, but then you cannot | 524 It is possible to use @key{ESC} as Meta, but then you cannot |
559 press @kbd{ESC} multiple times in Vi state. @xref{Customization}, to find | 525 press @key{ESC} multiple times in Vi state. @xref{Customization}, to find |
560 out how to rebind ESC to be Meta.@refill | 526 out how to rebind @key{ESC} to be Meta.@refill |
561 @end table | 527 @end table |
562 @noindent | 528 @noindent |
563 Other differences are mostly improvements. The ones you should know | 529 Other differences are mostly improvements. The ones you should know |
564 about are: | 530 about are: |
565 | 531 |
606 For path names, | 572 For path names, |
607 Emacs uses a convention that is slightly different from that of Unix. | 573 Emacs uses a convention that is slightly different from that of Unix. |
608 It is designed to minimize the need for deleting path names that Emacs | 574 It is designed to minimize the need for deleting path names that Emacs |
609 provides in its prompts. (This is usually convenient, but occasionally | 575 provides in its prompts. (This is usually convenient, but occasionally |
610 the prompt may suggest a wrong path name for you.) If you see a prompt | 576 the prompt may suggest a wrong path name for you.) If you see a prompt |
611 @kbd{/usr/foo/} and you wish to edit the file @kbd{~/.vip}, you don't | 577 @kbd{/usr/foo/} and you wish to edit the file @kbd{~/.viper}, you don't |
612 have to erase the prompt. Instead, simply continue typing what you | 578 have to erase the prompt. Instead, simply continue typing what you |
613 need. Emacs will interpret @kbd{/usr/foo/~/.vip} correctly. Similarly, | 579 need. Emacs will interpret @kbd{/usr/foo/~/.viper} correctly. Similarly, |
614 if the prompt is @kbd{~/foo/} and you need to get to @kbd{/bar/file}, keep | 580 if the prompt is @kbd{~/foo/} and you need to get to @kbd{/bar/file}, keep |
615 typing. Emacs interprets @kbd{~/foo//bar/} as @kbd{/bar/file}, since when it | 581 typing. Emacs interprets @kbd{~/foo//bar/} as @kbd{/bar/file}, since when it |
616 sees @samp{//}, it understands that @kbd{~/foo/} is to be discarded. | 582 sees @samp{//}, it understands that @kbd{~/foo/} is to be discarded. |
617 | 583 |
618 The command @kbd{:cd} will change the default directory for the | 584 The command @kbd{:cd} will change the default directory for the |
623 @kbd{:args}, so that @kbd{:rew} is obsolete. Also, @kbd{:args} will show only | 589 @kbd{:args}, so that @kbd{:rew} is obsolete. Also, @kbd{:args} will show only |
624 the invisible files (i.e., those that are not currently seen in Emacs | 590 the invisible files (i.e., those that are not currently seen in Emacs |
625 windows). | 591 windows). |
626 | 592 |
627 When applicable, Ex commands support file completion and history. This | 593 When applicable, Ex commands support file completion and history. This |
628 means that by typing a partial file name and then @kbd{TAB}, Emacs will try | 594 means that by typing a partial file name and then @key{TAB}, Emacs will try |
629 to complete the name or it will offer a menu of possible completions. | 595 to complete the name or it will offer a menu of possible completions. |
630 This works similarly to Tcsh and extends the behavior of Csh. While Emacs | 596 This works similarly to Tcsh and extends the behavior of Csh. While Emacs |
631 is waiting for a file name, you can type @kbd{M-p} to get the previous file | 597 is waiting for a file name, you can type @kbd{M-p} to get the previous file |
632 name you typed. Repeatedly typing @kbd{M-p} and @kbd{M-n} will let you | 598 name you typed. Repeatedly typing @kbd{M-p} and @kbd{M-n} will let you |
633 browse through the file history. | 599 browse through the file history. |
634 | 600 |
635 Like file names, partially typed Ex commands can be completed by typing | 601 Like file names, partially typed Ex commands can be completed by typing |
636 @kbd{TAB}, and Viper keeps the history of Ex commands. After typing | 602 @key{TAB}, and Viper keeps the history of Ex commands. After typing |
637 @kbd{:}, you can browse through the previously entered Ex commands by | 603 @kbd{:}, you can browse through the previously entered Ex commands by |
638 typing @kbd{M-p} and @kbd{M-n}. Viper tries to rationalize when it puts Ex | 604 typing @kbd{M-p} and @kbd{M-n}. Viper tries to rationalize when it puts Ex |
639 commands on the history list. For instance, if you typed @kbd{:w! foo}, | 605 commands on the history list. For instance, if you typed @kbd{:w! foo}, |
640 only @kbd{:w!} will be placed on the history list. This is because the | 606 only @kbd{:w!} will be placed on the history list. This is because the |
641 last history element is the default that can be invoked simply by typing | 607 last history element is the default that can be invoked simply by typing |
642 @kbd{: RET}. If @kbd{:w! foo} were placed on the list, it would be all to | 608 @kbd{: @key{RET}}. If @kbd{:w! foo} were placed on the list, it would be all to |
643 easy to override valuable data in another file. Reconstructing the full | 609 easy to override valuable data in another file. Reconstructing the full |
644 command, @kbd{:w! foo}, from the history is still not that hard, since Viper | 610 command, @kbd{:w! foo}, from the history is still not that hard, since Viper |
645 has a separate history for file names. By typing @kbd{: M-p}, you will get | 611 has a separate history for file names. By typing @kbd{: M-p}, you will get |
646 @kbd{:w!} in the Minibuffer. Then, repeated @kbd{M-p} will get you through | 612 @kbd{:w!} in the Minibuffer. Then, repeated @kbd{M-p} will get you through |
647 the file history, inserting one file name after another. | 613 the file history, inserting one file name after another. |
721 @cindex Replace state | 687 @cindex Replace state |
722 | 688 |
723 This state is entered through Vi replacement commands, such as @kbd{C}, | 689 This state is entered through Vi replacement commands, such as @kbd{C}, |
724 @kbd{cw}, etc., or by typing @kbd{R}. In Replace state, Viper puts <R> in the | 690 @kbd{cw}, etc., or by typing @kbd{R}. In Replace state, Viper puts <R> in the |
725 mode line to let you know which state is in effect. If Replace state is | 691 mode line to let you know which state is in effect. If Replace state is |
726 entered through @kbd{R}, Viper stays in that state until the user hits ESC. | 692 entered through @kbd{R}, Viper stays in that state until the user hits |
693 @key{ESC}. | |
727 If this state is entered via the other replacement commands, then Replace | 694 If this state is entered via the other replacement commands, then Replace |
728 state is in effect until you hit @kbd{ESC} or until you cross the rightmost | 695 state is in effect until you hit @key{ESC} or until you cross the rightmost |
729 boundary of the replacement region. In the latter case, Viper changes its | 696 boundary of the replacement region. In the latter case, Viper changes its |
730 state from Replace to Insert (which you will notice by the change in the | 697 state from Replace to Insert (which you will notice by the change in the |
731 mode line). | 698 mode line). |
732 | 699 |
733 Since Viper runs under Emacs, it is possible to switch between buffers | 700 Since Viper runs under Emacs, it is possible to switch between buffers |
736 unattainable in regular Vi), it is possible to take the cursor outside the | 703 unattainable in regular Vi), it is possible to take the cursor outside the |
737 replacement region. (This may be necessary for several reasons, including | 704 replacement region. (This may be necessary for several reasons, including |
738 the need to enable text selection and region-setting with the mouse.) | 705 the need to enable text selection and region-setting with the mouse.) |
739 | 706 |
740 The issue then arises as to what to do when the user | 707 The issue then arises as to what to do when the user |
741 hits the ESC key. In Vi, this would cause the text between cursor and | 708 hits the @key{ESC} key. In Vi, this would cause the text between cursor and |
742 the end of the replacement region to be deleted. But what if, as is | 709 the end of the replacement region to be deleted. But what if, as is |
743 possible in Viper, the cursor is not inside the replacement region? | 710 possible in Viper, the cursor is not inside the replacement region? |
744 | 711 |
745 To solve the problem, Viper keeps track of the last cursor position while it | 712 To solve the problem, Viper keeps track of the last cursor position while it |
746 was still inside the replacement region. So, in the above situation, Viper | 713 was still inside the replacement region. So, in the above situation, Viper |
762 Delete Word | 729 Delete Word |
763 @item C-u | 730 @item C-u |
764 Erase line | 731 Erase line |
765 @item C-v | 732 @item C-v |
766 Quote the following character | 733 Quote the following character |
767 @item RET | 734 @item @key{RET} |
768 Execute command | 735 Execute command |
769 @item C-g and C-] | 736 @item C-g and C-] |
770 Emacs quit and abort keys. These may be necessary. @xref{Vi State}, for an | 737 Emacs quit and abort keys. These may be necessary. @xref{Vi State}, for an |
771 explanation. | 738 explanation. |
772 @item M-p and M-n | 739 @item M-p and M-n |
781 can use the regular Vi commands to edit the Minibuffer. You can switch | 748 can use the regular Vi commands to edit the Minibuffer. You can switch |
782 between the Vi state and Insert state at will, and even use the replace mode. | 749 between the Vi state and Insert state at will, and even use the replace mode. |
783 Initially, the Minibuffer comes up in Insert state. | 750 Initially, the Minibuffer comes up in Insert state. |
784 | 751 |
785 Some users prefer plain Emacs bindings in the Minibuffer. To this end, set | 752 Some users prefer plain Emacs bindings in the Minibuffer. To this end, set |
786 @code{vip-vi-style-in-minibuffer} to @code{nil} in @file{.vip}. | 753 @code{vip-vi-style-in-minibuffer} to @code{nil} in @file{.viper}. |
787 @xref{Customization}, to learn how to do this. | 754 @xref{Customization}, to learn how to do this. |
788 | 755 |
789 When the Minibuffer changes Viper states, you will notice that the appearance | 756 When the Minibuffer changes Viper states, you will notice that the appearance |
790 of the text there changes as well. This is useful because the Minibuffer | 757 of the text there changes as well. This is useful because the Minibuffer |
791 has no mode line to tell which Vi state it is in. | 758 has no mode line to tell which Vi state it is in. |
815 @item Repeated Commands | 782 @item Repeated Commands |
816 Command repetitions are common over files. Typing @kbd{!!} will repeat the | 783 Command repetitions are common over files. Typing @kbd{!!} will repeat the |
817 last @kbd{!} command whichever file it was issued from. | 784 last @kbd{!} command whichever file it was issued from. |
818 Typing @kbd{.} will repeat the last command from any file, and | 785 Typing @kbd{.} will repeat the last command from any file, and |
819 searches will repeat the last search. Ex commands can be repeated by typing | 786 searches will repeat the last search. Ex commands can be repeated by typing |
820 @kbd{:RET}.@refill | 787 @kbd{: @key{RET}}.@refill |
821 Note: in some rare cases, that @kbd{:RET} may do something dangerous. | 788 Note: in some rare cases, that @kbd{: @key{RET}} may do something dangerous. |
822 However, usually its effect can be undone by typing @kbd{u}. | 789 However, usually its effect can be undone by typing @kbd{u}. |
823 @item Registers | 790 @item Registers |
824 @cindex registers | 791 @cindex registers |
825 Registers are common to files. Also, text yanked with @kbd{y} can be | 792 Registers are common to files. Also, text yanked with @kbd{y} can be |
826 put back (@kbd{p}) into any file. The Viper command @kbd{]<a-z>}, where <a-z> are | 793 put back (@kbd{p}) into any file. The Viper command @kbd{]<a-z>}, where <a-z> are |
844 file name in any | 811 file name in any |
845 @kbd{:e}, @kbd{:r}, @kbd{:w}, etc., command (in Emacs, each buffer has a | 812 @kbd{:e}, @kbd{:r}, @kbd{:w}, etc., command (in Emacs, each buffer has a |
846 current directory). | 813 current directory). |
847 This directory is inserted in the Minibuffer once you type space after | 814 This directory is inserted in the Minibuffer once you type space after |
848 @kbd{:e, r}, etc. Viper also supports completion of file names and Ex | 815 @kbd{:e, r}, etc. Viper also supports completion of file names and Ex |
849 commands (@kbd{TAB}), and it keeps track of | 816 commands (@key{TAB}), and it keeps track of |
850 command and file history (@kbd{M-p}, @kbd{M-n}). | 817 command and file history (@kbd{M-p}, @kbd{M-n}). |
851 Absolute filenames are required less | 818 Absolute filenames are required less |
852 often in Viper. | 819 often in Viper. |
853 | 820 |
854 You should be aware that Emacs interprets @kbd{/foo/bar//bla} as | 821 You should be aware that Emacs interprets @kbd{/foo/bar//bla} as |
976 | 943 |
977 In the Overview chapter, some Multiple File issues were discussed | 944 In the Overview chapter, some Multiple File issues were discussed |
978 (@xref{Multiple Files in Viper}). In addition to the files, Emacs has | 945 (@xref{Multiple Files in Viper}). In addition to the files, Emacs has |
979 buffers. These can be seen in the @kbd{:args} list and switched using | 946 buffers. These can be seen in the @kbd{:args} list and switched using |
980 @kbd{:next} if you type @kbd{:set ex-cycle-through-non-files t}, or | 947 @kbd{:next} if you type @kbd{:set ex-cycle-through-non-files t}, or |
981 specify @code{(setq ex-cycle-through-non-files t)} in your @file{.vip} | 948 specify @code{(setq ex-cycle-through-non-files t)} in your @file{.viper} |
982 file. @xref{Customization}, for details. | 949 file. @xref{Customization}, for details. |
983 | 950 |
984 @node Undo and Backups, History, Basics, Improvements over Vi | 951 @node Undo and Backups, History, Basics, Improvements over Vi |
985 @section Undo and Backups | 952 @section Undo and Backups |
986 | 953 |
1036 To move to previous and next history items. This causes the history | 1003 To move to previous and next history items. This causes the history |
1037 items to appear on the command line, where you can edit them, or | 1004 items to appear on the command line, where you can edit them, or |
1038 simply type Return to execute. | 1005 simply type Return to execute. |
1039 @item M-r and M-s | 1006 @item M-r and M-s |
1040 To search backward and forward through the history. | 1007 To search backward and forward through the history. |
1041 @item RET | 1008 @item @key{RET} |
1042 Type RET to accept a default (which is displayed in the prompt). | 1009 Type @key{RET} to accept a default (which is displayed in the prompt). |
1043 @end table | 1010 @end table |
1044 | 1011 |
1045 The history of insertions can be perused by | 1012 The history of insertions can be perused by |
1046 typing @kbd{C-c M-p} and @kbd{C-c M-n} while in Insert or Replace state. | 1013 typing @kbd{C-c M-p} and @kbd{C-c M-n} while in Insert or Replace state. |
1047 The history of destructive Vi commands can be perused via the same keys | 1014 The history of destructive Vi commands can be perused via the same keys |
1069 remembered (This is called ``learn mode'' in some editors.) | 1036 remembered (This is called ``learn mode'' in some editors.) |
1070 @kbd{@@register} will complete the macro, putting it into @samp{register}, | 1037 @kbd{@@register} will complete the macro, putting it into @samp{register}, |
1071 where @samp{register} is any character from @samp{a} through @samp{z}. Then | 1038 where @samp{register} is any character from @samp{a} through @samp{z}. Then |
1072 you can execute this macro using @kbd{@@register}. It is, of course, | 1039 you can execute this macro using @kbd{@@register}. It is, of course, |
1073 possible to yank some text into a register and execute it using | 1040 possible to yank some text into a register and execute it using |
1074 @kbd{@@register}. Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@LF} will | 1041 @kbd{@@register}. Typing @kbd{@@@@}, @kbd{@@RET}, or @kbd{@@C-j} will |
1075 execute the last macro that was executed using @kbd{@@register}.@refill | 1042 execute the last macro that was executed using @kbd{@@register}.@refill |
1076 | 1043 |
1077 Viper will automatically lowercase the register, so that pressing the | 1044 Viper will automatically lowercase the register, so that pressing the |
1078 @kbd{SHIFT} key for @kbd{@@} will not create problems. This is for | 1045 @kbd{SHIFT} key for @kbd{@@} will not create problems. This is for |
1079 @kbd{@@} macros and @kbd{"p} @emph{only}. In the case of @kbd{y}, | 1046 @kbd{@@} macros and @kbd{"p} @emph{only}. In the case of @kbd{y}, |
1106 @node Completion, Improved Search, Macros and Registers, Improvements over Vi | 1073 @node Completion, Improved Search, Macros and Registers, Improvements over Vi |
1107 @section Completion | 1074 @section Completion |
1108 | 1075 |
1109 @cindex completion | 1076 @cindex completion |
1110 | 1077 |
1111 Completion is done when you type @kbd{TAB}. The Emacs completer does not | 1078 Completion is done when you type @key{TAB}. The Emacs completer does not |
1112 grok wildcards in filenames. Once you type a wildcard, the completer will | 1079 grok wildcards in filenames. Once you type a wildcard, the completer will |
1113 no longer work for that path. Remember that Emacs interprets a file name | 1080 no longer work for that path. Remember that Emacs interprets a file name |
1114 of the form @kbd{/foo//bar} as @kbd{/bar} and @kbd{/foo/~/bar} as | 1081 of the form @kbd{/foo//bar} as @kbd{/bar} and @kbd{/foo/~/bar} as |
1115 @kbd{~/bar}. | 1082 @kbd{~/bar}. |
1116 | 1083 |
1119 | 1086 |
1120 @cindex buffer search | 1087 @cindex buffer search |
1121 @cindex word search | 1088 @cindex word search |
1122 | 1089 |
1123 Viper provides buffer search, the ability to search the buffer for a region | 1090 Viper provides buffer search, the ability to search the buffer for a region |
1124 under the cursor. You have to turn this on in @file{.vip} either by calling | 1091 under the cursor. You have to turn this on in @file{.viper} either by calling |
1125 | 1092 |
1126 @example | 1093 @example |
1127 (vip-buffer-search-enable) | 1094 (vip-buffer-search-enable) |
1128 @end example | 1095 @end example |
1129 | 1096 |
1170 @example | 1137 @example |
1171 (setq vip-search-face 'default) | 1138 (setq vip-search-face 'default) |
1172 @end example | 1139 @end example |
1173 @vindex @code{vip-search-face} | 1140 @vindex @code{vip-search-face} |
1174 @noindent | 1141 @noindent |
1175 in @file{~/.vip}. If you want to change how patterns are highlighted, you | 1142 in @file{~/.viper}. If you want to change how patterns are highlighted, you |
1176 will have to set the variable @code{vip-search-face} to some other face, | 1143 will have to set the variable @code{vip-search-face} to some other face, |
1177 such as @code{highlight}. If none of the existing faces fits the bill, you | 1144 such as @code{highlight}. If none of the existing faces fits the bill, you |
1178 would have to create your own. Further details on faces can be found | 1145 would have to create your own. Further details on faces can be found |
1179 in the Emacs Lisp Manual. | 1146 in the Emacs Lisp Manual. |
1180 | 1147 |
1196 one can type @samp{Abbreviations} by typing @samp{A}, followed by a keystroke | 1163 one can type @samp{Abbreviations} by typing @samp{A}, followed by a keystroke |
1197 that completed the @samp{A} to @samp{Abbreviations}. Repeated typing | 1164 that completed the @samp{A} to @samp{Abbreviations}. Repeated typing |
1198 will search further back in the buffer, so that one could get | 1165 will search further back in the buffer, so that one could get |
1199 @samp{Abbrevs} by repeating the | 1166 @samp{Abbrevs} by repeating the |
1200 keystroke, which appears earlier in the text. Emacs binds this to | 1167 keystroke, which appears earlier in the text. Emacs binds this to |
1201 @kbd{ESC /}, so you will have to find a key and bind the function | 1168 @kbd{@key{ESC} /}, so you will have to find a key and bind the function |
1202 @code{dabbrev-expand} to that key. | 1169 @code{dabbrev-expand} to that key. |
1203 Facilities like this make Vi's @kbd{:ab} command obsolete. | 1170 Facilities like this make Vi's @kbd{:ab} command obsolete. |
1204 | 1171 |
1205 @node Movement and Markers, New Commands, Abbreviation Facilities, Improvements over Vi | 1172 @node Movement and Markers, New Commands, Abbreviation Facilities, Improvements over Vi |
1206 @section Movement and Markers | 1173 @section Movement and Markers |
1207 | 1174 |
1208 @cindex Ex style motion | 1175 @cindex Ex style motion |
1209 @cindex line editor motion | 1176 @cindex line editor motion |
1210 | 1177 |
1211 Viper can be set free from the line--limited movements in Vi, such as @kbd{l} | 1178 Viper can be set free from the line--limited movements in Vi, such as @kbd{l} |
1212 refusing to move beyond the line, @kbd{ESC} moving one character back, | 1179 refusing to move beyond the line, @key{ESC} moving one character back, |
1213 etc. These derive from Ex, which is a line editor. If your @file{.vip} | 1180 etc. These derive from Ex, which is a line editor. If your @file{.viper} |
1214 contains | 1181 contains |
1215 | 1182 |
1216 @example | 1183 @example |
1217 @code{(setq vip-ex-style-motion nil)} | 1184 @code{(setq vip-ex-style-motion nil)} |
1218 @end example | 1185 @end example |
1227 @cindex syntax table | 1194 @cindex syntax table |
1228 | 1195 |
1229 The word-movement commands @kbd{w}, @kbd{e}, etc., and the associated | 1196 The word-movement commands @kbd{w}, @kbd{e}, etc., and the associated |
1230 deletion/yanking commands, @kbd{dw}, @kbd{yw}, etc., can be made to | 1197 deletion/yanking commands, @kbd{dw}, @kbd{yw}, etc., can be made to |
1231 understand Emacs syntax tables. If the variable | 1198 understand Emacs syntax tables. If the variable |
1232 @code{vip-syntax-preference} is set to @code{'strict-vi} (the default) then | 1199 @code{vip-syntax-preference} is set to @code{strict-vi} (the default) then |
1233 the meaning of @emph{word} is the same as in | 1200 the meaning of @emph{word} is the same as in |
1234 Vi. However, if the value is @code{'reformed-vi} then the alphanumeric | 1201 Vi. However, if the value is @code{reformed-vi} then the alphanumeric |
1235 symbols will be those specified by the current Emacs syntax table (which | 1202 symbols will be those specified by the current Emacs syntax table (which |
1236 may be different for different major modes) plus the underscore symbol | 1203 may be different for different major modes) plus the underscore symbol |
1237 @code{_}. The user can also specify the value @code{'emacs}, which would | 1204 @code{_}. The user can also specify the value @code{emacs}, which would |
1238 make Viper use exactly the Emacs notion of word. In particular, the | 1205 make Viper use exactly the Emacs notion of word. In particular, the |
1239 underscore may not be part of a word. Finally, if | 1206 underscore may not be part of a word. Finally, if |
1240 @code{vip-syntax-preference} is set to @code{'extended}, Viper words would | 1207 @code{vip-syntax-preference} is set to @code{extended}, Viper words would |
1241 consist of characters that are classified as alphanumeric @emph{or} as | 1208 consist of characters that are classified as alphanumeric @emph{or} as |
1242 parts of symbols. This is convenient for writing programs and in many other | 1209 parts of symbols. This is convenient for writing programs and in many other |
1243 situations. | 1210 situations. |
1244 | 1211 |
1245 @code{vip-syntax-preference} is a local variable, so it can have different | 1212 @code{vip-syntax-preference} is a local variable, so it can have different |
1246 values for different major modes. For instance, in programming modes it can | 1213 values for different major modes. For instance, in programming modes it can |
1247 have the value @code{'extended}. In text modes where words contain special | 1214 have the value @code{extended}. In text modes where words contain special |
1248 characters, such as European (non-English) letters, Cyrillic letters, etc., | 1215 characters, such as European (non-English) letters, Cyrillic letters, etc., |
1249 the value can be @code{'reformed-vi} or @code{'emacs}. | 1216 the value can be @code{reformed-vi} or @code{emacs}. |
1250 | 1217 |
1251 Changes to @code{vip-syntax-preference} should be done in the hooks to | 1218 Changes to @code{vip-syntax-preference} should be done in the hooks to |
1252 various major modes. Furthermore, for these changes to take effect, you | 1219 various major modes. Furthermore, for these changes to take effect, you |
1253 should execute @code{(vip-update-alphanumeric-class)} right after changing | 1220 should execute @code{(vip-update-alphanumeric-class)} right after changing |
1254 the value of @code{vip-syntax-preference}. | 1221 the value of @code{vip-syntax-preference}. |
1282 that you hit that key in Emacs state. For example, if you hit @kbd{C-x} | 1249 that you hit that key in Emacs state. For example, if you hit @kbd{C-x} |
1283 followed by @kbd{2}, then the current window will be split into 2 and you | 1250 followed by @kbd{2}, then the current window will be split into 2 and you |
1284 will be in Vi state again. Except for novice users, @kbd{C-c} is also set | 1251 will be in Vi state again. Except for novice users, @kbd{C-c} is also set |
1285 to temporarily escape to Emacs and execute a command from the current | 1252 to temporarily escape to Emacs and execute a command from the current |
1286 major mode. | 1253 major mode. |
1287 @kbd{ESC} will do the same, if | 1254 @key{ESC} will do the same, if |
1288 you configure @key{ESC} as Meta by setting @code{vip-no-multiple-ESC} to nil | 1255 you configure @key{ESC} as Meta by setting @code{vip-no-multiple-ESC} to nil |
1289 in @file{.vip}. @xref{Customization}. @kbd{C-\} | 1256 in @file{.viper}. @xref{Customization}. @kbd{C-\} |
1290 in Insert or Vi states will make Emacs think @kbd{Meta} has been hit.@refill | 1257 in Insert or Vi states will make Emacs think @kbd{Meta} has been hit.@refill |
1291 @item \ | 1258 @item \ |
1292 @kindex @kbd{\} | 1259 @kindex @kbd{\} |
1293 Escape to Emacs to execute a single Emacs command. For instance, @kbd{\ | 1260 Escape to Emacs to execute a single Emacs command. For instance, |
1294 ESC} will act like a Meta key. | 1261 @kbd{\ @key{ESC}} will act like a Meta key. |
1295 @item Q | 1262 @item Q |
1296 @kindex @kbd{Q} | 1263 @kindex @kbd{Q} |
1297 @cindex query replace | 1264 @cindex query replace |
1298 @kbd{Q} is for query replace. By default, | 1265 @kbd{Q} is for query replace. By default, |
1299 each string to be replaced is treated as a regular expression. You can use | 1266 each string to be replaced is treated as a regular expression. You can use |
1320 @kbd{s}. For instance, @kbd{#qr} will prompt you for a string and then | 1287 @kbd{s}. For instance, @kbd{#qr} will prompt you for a string and then |
1321 prepend this string to each line in the buffer.@refill | 1288 prepend this string to each line in the buffer.@refill |
1322 @item # c | 1289 @item # c |
1323 @kindex @kbd{#c<move>} | 1290 @kindex @kbd{#c<move>} |
1324 @cindex changing case | 1291 @cindex changing case |
1325 Change upper case characters in the region to lower case | 1292 Change upper-case characters in the region to lower-case |
1326 (@code{downcase-region}). | 1293 (@code{downcase-region}). |
1327 Emacs command @kbd{M-l} does the same for words. | 1294 Emacs command @kbd{M-l} does the same for words. |
1328 @item # C | 1295 @item # C |
1329 @kindex @kbd{#C<move>} | 1296 @kindex @kbd{#C<move>} |
1330 Change lower case characters in the region to upper case. For instance, | 1297 Change lower-case characters in the region to upper-case. For instance, |
1331 @kbd{# C 3 w} will capitalize 3 words from the current point | 1298 @kbd{# C 3 w} will capitalize 3 words from the current point |
1332 (@code{upcase-region}). | 1299 (@code{upcase-region}). |
1333 Emacs command @kbd{M-u} does the same for words. | 1300 Emacs command @kbd{M-u} does the same for words. |
1334 @item # g | 1301 @item # g |
1335 @kindex @kbd{#g<move>} | 1302 @kindex @kbd{#g<move>} |
1544 Customization can be done in 2 ways. | 1511 Customization can be done in 2 ways. |
1545 | 1512 |
1546 @itemize @bullet | 1513 @itemize @bullet |
1547 @item | 1514 @item |
1548 @cindex initialization | 1515 @cindex initialization |
1549 @cindex .vip | 1516 @cindex .viper |
1550 Elisp code in a @file{.vip} file in your home directory. Viper | 1517 Elisp code in a @file{.viper} file in your home directory. Viper |
1551 loads @file{.vip} just before it does the binding for mode | 1518 loads @file{.viper} just before it does the binding for mode |
1552 hooks. This is the recommended method. | 1519 hooks. This is the recommended method. |
1553 @item | 1520 @item |
1554 @cindex .emacs | 1521 @cindex .emacs |
1555 Elisp code in your @file{.emacs} file before and after the | 1522 Elisp code in your @file{.emacs} file before and after the |
1556 @code{(require 'viper)} line. This method is not recommended, unless you | 1523 @code{(require 'viper)} line. This method is not recommended, unless you |
1580 Viper. Here is the list of the constants used in Viper and their default | 1547 Viper. Here is the list of the constants used in Viper and their default |
1581 values. The corresponding :se command is also indicated. (The symbols | 1548 values. The corresponding :se command is also indicated. (The symbols |
1582 @code{t} and @code{nil} represent ``true'' and ``false'' in Lisp). | 1549 @code{t} and @code{nil} represent ``true'' and ``false'' in Lisp). |
1583 | 1550 |
1584 Viper supports both the abbreviated Vi variable names and their full | 1551 Viper supports both the abbreviated Vi variable names and their full |
1585 names. Variable completion is done on full names only. @kbd{TAB} and | 1552 names. Variable completion is done on full names only. @key{TAB} and |
1586 @kbd{SPC} complete | 1553 @key{SPC} complete |
1587 variable names. Typing `=' will complete the name and then will prompt for | 1554 variable names. Typing `=' will complete the name and then will prompt for |
1588 a value, if applicable. For instance, @kbd{:se auSPC} will complete the | 1555 a value, if applicable. For instance, @kbd{:se au @key{SPC}} will complete the |
1589 command to @kbd{:set autoindent}; @kbd{:se taSPC} will complete the command | 1556 command to @kbd{:set autoindent}; @kbd{:se ta @key{SPC}} will complete the command |
1590 and prompt further like this: @kbd{:set tabstop = }. | 1557 and prompt further like this: @kbd{:set tabstop = }. |
1591 However, typing @kbd{:se tsSPC} will produce a ``No match'' message | 1558 However, typing @kbd{:se ts @key{SPC}} will produce a ``No match'' message |
1592 because @kbd{ts} is an abbreviation for @kbd{tabstop} and Viper supports | 1559 because @kbd{ts} is an abbreviation for @kbd{tabstop} and Viper supports |
1593 completion on full names only. However, you can still hit @kbd{RET} | 1560 completion on full names only. However, you can still hit @key{RET} |
1594 or @kbd{=}, which will complete the command like this: @kbd{:set ts = } and | 1561 or @kbd{=}, which will complete the command like this: @kbd{:set ts = } and |
1595 Viper will be waiting for you to type a value for the tabstop variable. | 1562 Viper will be waiting for you to type a value for the tabstop variable. |
1596 To get the full list of Vi variables, type @kbd{:se SPC TAB}. | 1563 To get the full list of Vi variables, type @kbd{:se @key{SPC} @key{TAB}}. |
1597 | 1564 |
1598 @table @code | 1565 @table @code |
1599 @item vip-auto-indent nil | 1566 @item vip-auto-indent nil |
1600 @itemx :se ai (:se autoindent) | 1567 @itemx :se ai (:se autoindent) |
1601 @itemx :se gai (:se global-autoindent) | 1568 @itemx :se ai-g (:se autoindent-global) |
1602 If @code{t}, enable auto indentation. | 1569 If @code{t}, enable auto indentation. |
1603 by @kbd{RET}, @kbd{o} or @kbd{O} command. | 1570 by @key{RET}, @kbd{o} or @kbd{O} command. |
1604 | 1571 |
1605 @code{vip-auto-indent} is a local variable. To change the value globally, use | 1572 @code{vip-auto-indent} is a local variable. To change the value globally, use |
1606 @code{setq-default}. It may be useful for certain major modes to have their | 1573 @code{setq-default}. It may be useful for certain major modes to have their |
1607 own values of @code{vip-auto-indent}. This can be achieved by using | 1574 own values of @code{vip-auto-indent}. This can be achieved by using |
1608 @code{setq} to change the local value of this variable in the hooks to the | 1575 @code{setq} to change the local value of this variable in the hooks to the |
1610 | 1577 |
1611 @kbd{:se ai} changes the value of @code{vip-auto-indent} in the current | 1578 @kbd{:se ai} changes the value of @code{vip-auto-indent} in the current |
1612 buffer only; @kbd{:se gai} does the same globally. | 1579 buffer only; @kbd{:se gai} does the same globally. |
1613 @item vip-electric-mode t | 1580 @item vip-electric-mode t |
1614 If not @code{nil}, auto-indentation becomes electric, which means that | 1581 If not @code{nil}, auto-indentation becomes electric, which means that |
1615 @kbd{RET}, @kbd{O}, and @kbd{o} indent cursor according to the current | 1582 @key{RET}, @kbd{O}, and @kbd{o} indent cursor according to the current |
1616 major mode. In the future, this variable may control additional electric | 1583 major mode. In the future, this variable may control additional electric |
1617 features. | 1584 features. |
1618 | 1585 |
1619 This is a local variable: @code{setq} changes the value of this variable | 1586 This is a local variable: @code{setq} changes the value of this variable |
1620 in the current buffer only. Use @code{setq-default} to change the value in | 1587 in the current buffer only. Use @code{setq-default} to change the value in |
1635 @item blink-matching-paren t | 1602 @item blink-matching-paren t |
1636 @itemx :se sm (:se showmatch) | 1603 @itemx :se sm (:se showmatch) |
1637 Show matching parens by blinking cursor. | 1604 Show matching parens by blinking cursor. |
1638 @item tab-width t (default setting via @code{setq-default}) | 1605 @item tab-width t (default setting via @code{setq-default}) |
1639 @itemx :se ts=value (:se tabstop=value) | 1606 @itemx :se ts=value (:se tabstop=value) |
1640 @itemx :se gts=value (:se global-tabstop=value) | 1607 @itemx :se ts-g=value (:se tabstop-global=value) |
1641 @code{tab-width} is a local variable that controls the width of the tab stops. | 1608 @code{tab-width} is a local variable that controls the width of the tab stops. |
1642 To change the value globally, use @code{setq-default}; for local settings, | 1609 To change the value globally, use @code{setq-default}; for local settings, |
1643 use @code{setq}. | 1610 use @code{setq}. |
1644 | 1611 |
1645 The command @kbd{:se ts} | 1612 The command @kbd{:se ts} |
1648 | 1615 |
1649 The command @kbd{:se gts} sets tab width globally, | 1616 The command @kbd{:se gts} sets tab width globally, |
1650 for all buffers where the tab is not yet set locally, | 1617 for all buffers where the tab is not yet set locally, |
1651 including the new buffers. | 1618 including the new buffers. |
1652 | 1619 |
1653 Note that typing @kbd{TAB} normally | 1620 Note that typing @key{TAB} normally |
1654 doesn't insert the tab, since this key is usually bound to | 1621 doesn't insert the tab, since this key is usually bound to |
1655 a text-formatting function, @code{indent-for-tab-command} (which facilitates | 1622 a text-formatting function, @code{indent-for-tab-command} (which facilitates |
1656 programming and document writing). Instead, the tab is inserted via the | 1623 programming and document writing). Instead, the tab is inserted via the |
1657 command @code{vip-insert-tab}, which is bound to @kbd{S-tab} (shift + tab). | 1624 command @code{vip-insert-tab}, which is bound to @kbd{S-tab} (shift + tab). |
1658 | 1625 |
1659 On some non-windowing terminals, Shift doesn't modify the @kbd{TAB} key, so | 1626 On some non-windowing terminals, Shift doesn't modify the @key{TAB} key, so |
1660 @kbd{S-tab} behaves as if it were @kbd{TAB}. In such a case, you will have | 1627 @kbd{S-tab} behaves as if it were @key{TAB}. In such a case, you will have |
1661 to bind @code{vip-insert-tab} to some other convenient key. | 1628 to bind @code{vip-insert-tab} to some other convenient key. |
1662 | 1629 |
1663 @item vip-shift-width 8 | 1630 @item vip-shift-width 8 |
1664 @itemx :se sw=value (:se shiftwidth=value) | 1631 @itemx :se sw=value (:se shiftwidth=value) |
1665 The number of columns shifted by @kbd{>} and @kbd{<} commands. | 1632 The number of columns shifted by @kbd{>} and @kbd{<} commands. |
1680 @item vip-vi-style-in-minibuffer t | 1647 @item vip-vi-style-in-minibuffer t |
1681 If not @code{nil}, Viper provides a high degree of compatibility with Vi | 1648 If not @code{nil}, Viper provides a high degree of compatibility with Vi |
1682 insert mode when you type text in the Minibuffer; if @code{nil}, typing in | 1649 insert mode when you type text in the Minibuffer; if @code{nil}, typing in |
1683 the Minibuffer feels like plain Emacs. | 1650 the Minibuffer feels like plain Emacs. |
1684 @item vip-no-multiple-ESC t | 1651 @item vip-no-multiple-ESC t |
1685 If you set this to @code{nil}, you can use @kbd{ESC} as Meta in Vi state. | 1652 If you set this to @code{nil}, you can use @key{ESC} as Meta in Vi state. |
1686 Normally, this is not necessary, since graphical displays have separate | 1653 Normally, this is not necessary, since graphical displays have separate |
1687 Meta keys (usually on each side of the space bar). On a dumb terminal, Viper | 1654 Meta keys (usually on each side of the space bar). On a dumb terminal, Viper |
1688 sets this variable to @code{twice}, which is almost like @code{nil}, except | 1655 sets this variable to @code{twice}, which is almost like @code{nil}, except |
1689 that double @kbd{ESC} beeps. This, too, lets ESC to be used as a Meta. | 1656 that double @key{ESC} beeps. This, too, lets @key{ESC} to be used as a Meta. |
1690 @item vip-keysequence-delay 140 | 1657 @item vip-keysequence-delay 140 |
1691 Escape sequences separated by this much delay are interpreted as command, | 1658 Escape sequences separated by this much delay are interpreted as command, |
1692 ignoring the special meaning of ESC in VI. The default is suitable for most | 1659 ignoring the special meaning of @key{ESC} in VI. The default is suitable |
1693 terminals. However, if your terminal is extremely slow, you | 1660 for most terminals. However, if your terminal is extremely slow, you might |
1694 might want to increase this slightly. You will know if your terminal is | 1661 want to increase this slightly. You will know if your terminal is slow if |
1695 slow if the ESC key sequences emitted by the arrow keys are interpreted as | 1662 the @key{ESC} key sequences emitted by the arrow keys are interpreted as |
1696 separately typed characters (and thus the arrow keys won't work). | 1663 separately typed characters (and thus the arrow keys won't work). Making |
1697 Making this value too large will slow you down, so exercise restraint. | 1664 this value too large will slow you down, so exercise restraint. |
1698 @item vip-ex-style-motion t | 1665 @item vip-ex-style-motion t |
1699 Set this to @code{nil}, if you want @kbd{l,h} to cross | 1666 Set this to @code{nil}, if you want @kbd{l,h} to cross |
1700 lines, etc. @xref{Movement and Markers}, for more info. | 1667 lines, etc. @xref{Movement and Markers}, for more info. |
1701 @item vip-ex-style-editing-in-insert t | 1668 @item vip-ex-style-editing-in-insert t |
1702 Set this to to @code{nil}, if you want @kbd{ESC} to not move back and | 1669 Set this to to @code{nil}, if you want @key{ESC} to not move back and |
1703 @kbd{C-h} to not stop | 1670 @kbd{C-h} to not stop |
1704 at the beginning of a line in Insert state. | 1671 at the beginning of a line in Insert state. |
1705 @item vip-always t | 1672 @item viper-always t |
1706 Leave it to Viper to decide when a buffer must be brought up in Vi state, | 1673 @code{t} means: leave it to Viper to decide when a buffer must be brought |
1674 up in Vi state, | |
1707 Insert state, or Emacs state. This heuristics works well in virtually all | 1675 Insert state, or Emacs state. This heuristics works well in virtually all |
1708 cases. | 1676 cases. @code{nil} means you either has to invoke @code{viper-mode} manually |
1709 This option must be | 1677 for each buffer (or you can add @code{viper-mode} to the appropriate major mode |
1710 set before Viper is loaded or in the @file{.vip} file. | 1678 hooks using @code{vip-load-hook}). |
1711 @item vip-custom-file-name "~/.vip" | 1679 |
1712 Change this if you want. Must be set in @file{.emacs} (not @file{.vip}!) | 1680 This option must be set in the file @file{~/.viper}. |
1681 @item vip-custom-file-name "~/.viper" | |
1682 File used for Viper-specific customization. | |
1683 Change this setting, if you want. Must be set in @file{.emacs} (not @file{.viper}!) | |
1713 before Viper is loaded. Note that you | 1684 before Viper is loaded. Note that you |
1714 have to set it as a string inside double quotes. | 1685 have to set it as a string inside double quotes. |
1715 @item vip-spell-function 'ispell-region | 1686 @item vip-spell-function 'ispell-region |
1716 Function used by the command @kbd{#c<move>} to spell. | 1687 Function used by the command @kbd{#c<move>} to spell. |
1717 @item ex-nontrivial-find-file-function | 1688 @item ex-nontrivial-find-file-function |
1766 the second-last and the third-last destructive command. | 1737 the second-last and the third-last destructive command. |
1767 Both these macros are bound (as Viper macros) to | 1738 Both these macros are bound (as Viper macros) to |
1768 @code{vip-repeat-from-history}, | 1739 @code{vip-repeat-from-history}, |
1769 which checks the second key by which it is invoked to see which of the | 1740 which checks the second key by which it is invoked to see which of the |
1770 previous commands to invoke. Viper binds @kbd{f12 1} and @kbd{f12 2} only, | 1741 previous commands to invoke. Viper binds @kbd{f12 1} and @kbd{f12 2} only, |
1771 but the user can bind more in @file{~/.vip}. @xref{Vi Macros}, for how to do | 1742 but the user can bind more in @file{~/.viper}. @xref{Vi Macros}, for how to do |
1772 this. | 1743 this. |
1773 @item vip-keep-point-on-undo nil | 1744 @item vip-keep-point-on-undo nil |
1774 If not @code{nil}, Viper tries to not move point when undoing commands. | 1745 If not @code{nil}, Viper tries to not move point when undoing commands. |
1775 Instead, it will briefly move the cursor to the place where change has | 1746 Instead, it will briefly move the cursor to the place where change has |
1776 taken place. However, if the undone piece of text is not seen in window, | 1747 taken place. However, if the undone piece of text is not seen in window, |
1777 then point will be moved to the place where the change took place. | 1748 then point will be moved to the place where the change took place. |
1778 Set it to @code{t} and see if you like it better. | 1749 Set it to @code{t} and see if you like it better. |
1779 @item vip-delete-backwards-in-replace nil | 1750 @item vip-delete-backwards-in-replace nil |
1780 If not @code{nil}, DEL key will delete characters while moving the cursor | 1751 If not @code{nil}, @key{DEL} key will delete characters while moving the cursor |
1781 backwards. If @code{nil}, the cursor will move backwards without deleting | 1752 backwards. If @code{nil}, the cursor will move backwards without deleting |
1782 anything. | 1753 anything. |
1783 @item vip-replace-overlay-face 'vip-replace-overlay-face | 1754 @item vip-replace-overlay-face 'vip-replace-overlay-face |
1784 @itemx vip-replace-overlay-pixmap "grey3" | 1755 @itemx vip-replace-overlay-pixmap "grey3" |
1785 On a graphical display, Viper highlights replacement regions instead of | 1756 On a graphical display, Viper highlights replacement regions instead of |
1835 the replacement mode. In this variable is set to @code{nil}, Viper will | 1806 the replacement mode. In this variable is set to @code{nil}, Viper will |
1836 emulate the standard Vi behavior, which supports only intra-line | 1807 emulate the standard Vi behavior, which supports only intra-line |
1837 replacement regions (and multi-line replacement regions are deleted). | 1808 replacement regions (and multi-line replacement regions are deleted). |
1838 @item vip-toggle-key "\C-z" | 1809 @item vip-toggle-key "\C-z" |
1839 Specifies the key used to switch from Emacs to Vi and back. | 1810 Specifies the key used to switch from Emacs to Vi and back. |
1840 Must be set in @file{.vip} or prior to loading Viper. This variable can't be | 1811 Must be set in @file{.viper} or prior to loading Viper. This variable can't be |
1841 changed interactively after Viper is loaded. | 1812 changed interactively after Viper is loaded. |
1842 | 1813 |
1843 In Insert state, this key acts as a temporary escape to Vi state, i.e., it | 1814 In Insert state, this key acts as a temporary escape to Vi state, i.e., it |
1844 will set Viper up so that the very next command will be executed as if it | 1815 will set Viper up so that the very next command will be executed as if it |
1845 were typed in Vi state. | 1816 were typed in Vi state. |
1846 @item vip-ESC-key "\e" | 1817 @item vip-ESC-key "\e" |
1847 Specifies the key used to escape from Insert/Replace states to Vi. | 1818 Specifies the key used to escape from Insert/Replace states to Vi. |
1848 Must be set in @file{.vip} or prior to loading Viper. This variable cannot be | 1819 Must be set in @file{.viper} or prior to loading Viper. This variable cannot be |
1849 changed interactively after Viper is loaded. | 1820 changed interactively after Viper is loaded. |
1850 @item vip-buffer-search-char nil | 1821 @item vip-buffer-search-char nil |
1851 Key used for buffer search. @xref{Viper Specials}, for details. | 1822 Key used for buffer search. @xref{Viper Specials}, for details. |
1852 @item vip-surrounding-word-function 'vip-surrounding-word | 1823 @item vip-surrounding-word-function 'vip-surrounding-word |
1853 The value of this variable is a function name that is used to determine | 1824 The value of this variable is a function name that is used to determine |
1872 the last chance to do customization before Viper is up and running. | 1843 the last chance to do customization before Viper is up and running. |
1873 @end table | 1844 @end table |
1874 @noindent | 1845 @noindent |
1875 You can reset some of these constants in Viper with the Ex command @kbd{:set} | 1846 You can reset some of these constants in Viper with the Ex command @kbd{:set} |
1876 (when so indicated in the table). Or you | 1847 (when so indicated in the table). Or you |
1877 can include a line like this in your @file{.vip} file: | 1848 can include a line like this in your @file{.viper} file: |
1878 @example | 1849 @example |
1879 (setq vip-case-fold-search t) | 1850 (setq vip-case-fold-search t) |
1880 @end example | 1851 @end example |
1881 @vindex @code{vip-auto-indent} | 1852 @vindex @code{vip-auto-indent} |
1882 @vindex @code{vip-electric-mode} | 1853 @vindex @code{vip-electric-mode} |
1890 @vindex @code{vip-tags-file-name} | 1861 @vindex @code{vip-tags-file-name} |
1891 @vindex @code{vip-re-query-replace} | 1862 @vindex @code{vip-re-query-replace} |
1892 @vindex @code{vip-want-ctl-h-help} | 1863 @vindex @code{vip-want-ctl-h-help} |
1893 @vindex @code{vip-vi-style-in-minibuffer} | 1864 @vindex @code{vip-vi-style-in-minibuffer} |
1894 @vindex @code{vip-no-multiple-ESC} | 1865 @vindex @code{vip-no-multiple-ESC} |
1895 @vindex @code{vip-always} | 1866 @vindex @code{viper-always} |
1896 @vindex @code{vip-keysequence-delay} | 1867 @vindex @code{vip-keysequence-delay} |
1897 @vindex @code{vip-ex-style-motion} | 1868 @vindex @code{vip-ex-style-motion} |
1898 @vindex @code{vip-ex-style-editing-in-insert} | 1869 @vindex @code{vip-ex-style-editing-in-insert} |
1899 @vindex @code{vip-custom-file-name} | 1870 @vindex @code{vip-custom-file-name} |
1900 @vindex @code{vip-spell-function} | 1871 @vindex @code{vip-spell-function} |
1985 | 1956 |
1986 @noindent | 1957 @noindent |
1987 If you want to | 1958 If you want to |
1988 bind a key, say @kbd{C-v}, to the function that scrolls | 1959 bind a key, say @kbd{C-v}, to the function that scrolls |
1989 page down and to make @kbd{0} display information on the current buffer, | 1960 page down and to make @kbd{0} display information on the current buffer, |
1990 putting this in @file{.vip} will do the trick in Vi state: | 1961 putting this in @file{.viper} will do the trick in Vi state: |
1991 @example | 1962 @example |
1992 (define-key vip-vi-global-user-map "\C-v" 'scroll-down) | 1963 (define-key vip-vi-global-user-map "\C-v" 'scroll-down) |
1993 @end example | 1964 @end example |
1994 @noindent | 1965 @noindent |
1995 To set a key globally, | 1966 To set a key globally, |
2033 @example | 2004 @example |
2034 (vip-modify-major-mode 'dired-mode 'emacs-state my-fancy-map) | 2005 (vip-modify-major-mode 'dired-mode 'emacs-state my-fancy-map) |
2035 @end example | 2006 @end example |
2036 | 2007 |
2037 @noindent | 2008 @noindent |
2038 in @file{~/.vip}. To do the same in Vi and Insert states, one should use | 2009 in @file{~/.viper}. To do the same in Vi and Insert states, one should use |
2039 @code{vi-state} and @code{insert-state}. Changes in Insert state are also | 2010 @code{vi-state} and @code{insert-state}. Changes in Insert state are also |
2040 in effect in Replace state. For instance, suppose that the user wants to | 2011 in effect in Replace state. For instance, suppose that the user wants to |
2041 use @kbd{dd} in Vi state under Dired mode to delete files, @kbd{u} to unmark | 2012 use @kbd{dd} in Vi state under Dired mode to delete files, @kbd{u} to unmark |
2042 files, etc. The following code in @file{~/.vip} will then do the job: | 2013 files, etc. The following code in @file{~/.viper} will then do the job: |
2043 | 2014 |
2044 @example | 2015 @example |
2045 (setq my-dired-modifier-map (make-sparse-keymap)) | 2016 (setq my-dired-modifier-map (make-sparse-keymap)) |
2046 (define-key my-dired-modifier-map "dd" 'dired-flag-file-deletion) | 2017 (define-key my-dired-modifier-map "dd" 'dired-flag-file-deletion) |
2047 (define-key my-dired-modifier-map "u" 'dired-unmark) | 2018 (define-key my-dired-modifier-map "u" 'dired-unmark) |
2073 aforesaid modifications may not take place immediately (but only after the | 2044 aforesaid modifications may not take place immediately (but only after the |
2074 buffer switches to some other Viper state and then back to Emacs state). To | 2045 buffer switches to some other Viper state and then back to Emacs state). To |
2075 avoid this, one should add @code{vip-change-state-to-emacs} to an | 2046 avoid this, one should add @code{vip-change-state-to-emacs} to an |
2076 appropriate hook of that major mode. (Check the function | 2047 appropriate hook of that major mode. (Check the function |
2077 @code{vip-set-hooks} in @file{viper.el} for examples.) However, if you | 2048 @code{vip-set-hooks} in @file{viper.el} for examples.) However, if you |
2078 have set @code{vip-always} to @code{t}, chances are that you won't need to | 2049 have set @code{viper-always} to @code{t}, chances are that you won't need to |
2079 perform the above procedure, because Viper will take care of most useful | 2050 perform the above procedure, because Viper will take care of most useful |
2080 defaults. | 2051 defaults. |
2081 | 2052 |
2082 | 2053 |
2083 Finally, Viper has a facility that lets the user define per-buffer | 2054 Finally, Viper has a facility that lets the user define per-buffer |
2120 (add-hook 'mh-letter-mode-hook 'mh-add-vi-keys) | 2091 (add-hook 'mh-letter-mode-hook 'mh-add-vi-keys) |
2121 @end lisp | 2092 @end lisp |
2122 | 2093 |
2123 You can also use @code{vip-add-local-keys} to set per buffer | 2094 You can also use @code{vip-add-local-keys} to set per buffer |
2124 bindings in Insert state and Emacs state by passing as a parameter the | 2095 bindings in Insert state and Emacs state by passing as a parameter the |
2125 symbols @code{'insert-state} and @code{'emacs-state}, respectively. | 2096 symbols @code{insert-state} and @code{emacs-state}, respectively. |
2126 As with global bindings, customized local bindings done to Emacs state | 2097 As with global bindings, customized local bindings done to Emacs state |
2127 are not inherited by Insert state. | 2098 are not inherited by Insert state. |
2128 | 2099 |
2129 On rare occasions, local keys may be added by mistake. Usually this is done | 2100 On rare occasions, local keys may be added by mistake. Usually this is done |
2130 indirectly, by invoking a major mode that adds local keys (e.g., | 2101 indirectly, by invoking a major mode that adds local keys (e.g., |
2131 @code{shell-mode} redefines @kbd{RET}). In such a case, exiting the wrong | 2102 @code{shell-mode} redefines @key{RET}). In such a case, exiting the wrong |
2132 major mode won't rid you from unwanted local keys, since these keys are | 2103 major mode won't rid you from unwanted local keys, since these keys are |
2133 local to Viper state and the current buffer, not to the major mode. | 2104 local to Viper state and the current buffer, not to the major mode. |
2134 In such situations, the remedy is to type @kbd{M-x vip-zap-local-keys}. | 2105 In such situations, the remedy is to type @kbd{M-x vip-zap-local-keys}. |
2135 | 2106 |
2136 So much about Viper-specific bindings. | 2107 So much about Viper-specific bindings. |
2153 Viper is designed to coexist with all major and minor modes of Emacs. This | 2124 Viper is designed to coexist with all major and minor modes of Emacs. This |
2154 means that bindings set by those modes are generally available with Viper | 2125 means that bindings set by those modes are generally available with Viper |
2155 (unless you explicitly prohibit them by setting | 2126 (unless you explicitly prohibit them by setting |
2156 @code{vip-want-emacs-keys-in-vi} and @code{vip-want-emacs-keys-in-insert} to | 2127 @code{vip-want-emacs-keys-in-vi} and @code{vip-want-emacs-keys-in-insert} to |
2157 @code{nil}). | 2128 @code{nil}). |
2158 If @code{vip-always} is set to @code{t}, Viper will try to bring each buffer | 2129 If @code{viper-always} is set to @code{t}, Viper will try to bring each buffer |
2159 in the a Viper state that is most appropriate for that buffer. | 2130 in the Viper state that is most appropriate for that buffer. |
2160 Usually, this would be the Vi state, but sometimes it could be the Insert | 2131 Usually, this would be the Vi state, but sometimes it could be the Insert |
2161 state or the Emacs state. | 2132 state or the Emacs state. |
2162 | 2133 |
2163 Some major mode bindings will necessarily be overwritten by Viper. Indeed, in | 2134 Some major mode bindings will necessarily be overwritten by Viper. Indeed, in |
2164 Vi state, most of the 1-character keys are used for Vi-style editing. This | 2135 Vi state, most of the 1-character keys are used for Vi-style editing. This |
2165 usually causes no problems because most packages designed for editing files | 2136 usually causes no problems because most packages designed for editing files |
2166 typically do not bind such keys. Instead, they use key sequences that start | 2137 typically do not bind such keys. Instead, they use key sequences that start |
2167 with @kbd{C-x} and @kbd{C-c}. This is why it was so important for us to | 2138 with @kbd{C-x} and @kbd{C-c}. This is why it was so important for us to |
2168 free up @kbd{C-x} and @kbd{C-c}. | 2139 free up @kbd{C-x} and @kbd{C-c}. |
2169 It is common for language-specific major modes to bind @kbd{TAB} and | 2140 It is common for language-specific major modes to bind @key{TAB} and |
2170 @kbd{LFD} (the line feed) keys to various formatting functions. This is | 2141 @kbd{C-j} (the line feed) keys to various formatting functions. This is |
2171 extremely useful, but may require some getting used to for a Vi user. If you | 2142 extremely useful, but may require some getting used to for a Vi user. If you |
2172 decide that this feature is not for you, you can re-bind these keys as | 2143 decide that this feature is not for you, you can re-bind these keys as |
2173 explained earlier (@xref{Customization}). | 2144 explained earlier (@xref{Customization}). |
2174 | 2145 |
2175 Binding for @kbd{TAB} is one of the most unusual aspects of Viper for many | 2146 Binding for @key{TAB} is one of the most unusual aspects of Viper for many |
2176 novice users. In Emacs, @kbd{TAB} is used to format text and programs, and | 2147 novice users. In Emacs, @key{TAB} is used to format text and programs, and |
2177 is extremely useful. For instance, hitting @kbd{TAB} causes the current | 2148 is extremely useful. For instance, hitting @key{TAB} causes the current |
2178 line to be re-indented in accordance with the context. In programming, | 2149 line to be re-indented in accordance with the context. In programming, |
2179 this is very important, since improper automatic indentation would | 2150 this is very important, since improper automatic indentation would |
2180 immediately alert the programmer to a possible error. For instance, if a | 2151 immediately alert the programmer to a possible error. For instance, if a |
2181 @kbd{)} or a @kbd{"} is missing somewhere above the current | 2152 @kbd{)} or a @kbd{"} is missing somewhere above the current |
2182 line, @kbd{TAB} is likely to mis-indent the line. | 2153 line, @key{TAB} is likely to mis-indent the line. |
2183 | 2154 |
2184 For this reason, Viper doesn't change the standard Emacs binding of | 2155 For this reason, Viper doesn't change the standard Emacs binding of |
2185 @kbd{TAB}, thereby sacrificing Vi compatibility | 2156 @key{TAB}, thereby sacrificing Vi compatibility |
2186 (except for users at level 1). Instead, in Viper, the key | 2157 (except for users at level 1). Instead, in Viper, the key |
2187 @kbd{S-tab} (shift+ tab) is chosen to emulate Vi's @kbd{TAB}. | 2158 @kbd{S-tab} (shift+ tab) is chosen to emulate Vi's @key{TAB}. |
2188 | 2159 |
2189 We should note that on some non-windowing terminals, Shift doesn't modify | 2160 We should note that on some non-windowing terminals, Shift doesn't modify |
2190 the @kbd{TAB} key, so @kbd{S-tab} behaves as if it were @kbd{TAB}. In such | 2161 the @key{TAB} key, so @kbd{S-tab} behaves as if it were @key{TAB}. In such |
2191 a case, you will have to bind @code{vip-insert-tab} to some other | 2162 a case, you will have to bind @code{vip-insert-tab} to some other |
2192 convenient key. | 2163 convenient key. |
2193 | 2164 |
2194 Some packages, notably Dired, Gnus, Info, etc., attach special meaning to | 2165 Some packages, notably Dired, Gnus, Info, etc., attach special meaning to |
2195 common keys like @kbd{SPC}, @kbd{x}, @kbd{d}, @kbd{v}, and others. This | 2166 common keys like @key{SPC}, @kbd{x}, @kbd{d}, @kbd{v}, and others. This |
2196 means that Vi command state is inappropriate for working with these | 2167 means that Vi command state is inappropriate for working with these |
2197 packages. Fortunately, these modes operate on read-only buffers and are | 2168 packages. Fortunately, these modes operate on read-only buffers and are |
2198 designed not for editing files, but for special-purpose browsing, reading | 2169 designed not for editing files, but for special-purpose browsing, reading |
2199 news, mail, etc., and Vi commands are meaningless in these situations. For | 2170 news, mail, etc., and Vi commands are meaningless in these situations. For |
2200 this reason, Viper doesn't force Vi state on such major modes. Rather, it | 2171 this reason, Viper doesn't force Vi state on such major modes. Rather, it |
2208 Vi-style, unless these keys perform essential duties.) | 2179 Vi-style, unless these keys perform essential duties.) |
2209 | 2180 |
2210 It is also possible to harness some major modes, even though they may bind | 2181 It is also possible to harness some major modes, even though they may bind |
2211 common keys to specialized commands. Harnessing can make sense for modes | 2182 common keys to specialized commands. Harnessing can make sense for modes |
2212 that bind only a small number of common keys. For instance, if | 2183 that bind only a small number of common keys. For instance, if |
2213 @code{vip-always} is set to @code{t} in your @file{~/.vip} file, Viper will | 2184 @code{viper-always} is set to @code{t} in your @file{~/.viper} file, Viper will |
2214 harness the Shell mode by changing the bindings for @kbd{C-m} and @kbd{C-d} | 2185 harness Shell mode by changing the bindings for @kbd{C-m} and @kbd{C-d} |
2215 using @code{vip-add-local-keys} described in section on customization | 2186 using @code{vip-add-local-keys} described in section on customization |
2216 (@xref{Customization}). In general, there is no single recipe for | 2187 (@xref{Customization}). In general, there is no single recipe for |
2217 harnessing modes. It can be as simple as adding the function | 2188 harnessing modes. It can be as simple as adding the function |
2218 @code{viper-mode} to a hook associated with the mode, or it can be more | 2189 @code{viper-mode} to a hook associated with the mode, or it can be more |
2219 complex, as in the case of Shell mode and Emerge. Take a look at | 2190 complex, as in the case of Shell mode and Emerge. Take a look at |
2220 @code{vip-set-hooks} function for some examples. | 2191 @code{vip-set-hooks} function for some examples. |
2221 | 2192 |
2222 Conversely, it may be the case that most of the major modes harnessed | 2193 Conversely, it may be the case that most of the major modes harnessed |
2223 by @code{vip-set-hooks} function fit your working style, except one or two | 2194 by @code{vip-set-hooks} function fit your working style, except one or two |
2224 cases. In this case, you may still be able to set @code{vip-always} to | 2195 cases. In this case, you may still be able to set @code{viper-always} to |
2225 @code{t} and then remove a hook that forces Vi command state. For instance, | 2196 @code{t} and then remove a hook that forces Vi command state. For instance, |
2226 to unharness @code{lisp-interaction-mode}, you can put the following line | 2197 to unharness @code{lisp-interaction-mode}, you can put the following line |
2227 in your @file{.emacs} (not @code{.vip}!) file after @code{(require 'viper)}: | 2198 in your @file{.emacs} (not @code{.viper}!) file after @code{(require 'viper)}: |
2228 @lisp | 2199 @lisp |
2229 (remove-hook 'lisp-interaction-mode-hook 'viper-mode) | 2200 (remove-hook 'lisp-interaction-mode-hook 'viper-mode) |
2230 @end lisp | 2201 @end lisp |
2231 | 2202 |
2232 In some rare cases, some minor modes may override certain essential | 2203 In some rare cases, some minor modes may override certain essential |
2234 may happen only in the beginning, when the minor mode kicks in. Typing | 2205 may happen only in the beginning, when the minor mode kicks in. Typing |
2235 @code{M-x viper-mode} will correct the situation. Viper knows about | 2206 @code{M-x viper-mode} will correct the situation. Viper knows about |
2236 several such minor modes and takes care of them, so that the above trick | 2207 several such minor modes and takes care of them, so that the above trick |
2237 is usually not necessary. If you find that some minor mode, e.g., | 2208 is usually not necessary. If you find that some minor mode, e.g., |
2238 @code{nasty-mode.el} interferes with Viper, putting the following in | 2209 @code{nasty-mode.el} interferes with Viper, putting the following in |
2239 @file{.vip} should fix the problem: | 2210 @file{.viper} should fix the problem: |
2240 @lisp | 2211 @lisp |
2241 (vip-harness-minor-mode "nasty-mode") | 2212 (vip-harness-minor-mode "nasty-mode") |
2242 @end lisp | 2213 @end lisp |
2243 @noindent | 2214 @noindent |
2244 The argument to @code{vip-harness-minor-mode} is the name of the file for the | 2215 The argument to @code{vip-harness-minor-mode} is the name of the file for the |
2257 suspicion is wrong, no harm is done if you harness a minor mode that | 2228 suspicion is wrong, no harm is done if you harness a minor mode that |
2258 doesn't need to be harnessed. | 2229 doesn't need to be harnessed. |
2259 | 2230 |
2260 @vindex @code{vip-want-emacs-keys-in-vi} | 2231 @vindex @code{vip-want-emacs-keys-in-vi} |
2261 @vindex @code{vip-want-emacs-keys-in-insert} | 2232 @vindex @code{vip-want-emacs-keys-in-insert} |
2262 @vindex @code{vip-always} | 2233 @vindex @code{viper-always} |
2263 @findex @code{vip-set-hooks} | 2234 @findex @code{vip-set-hooks} |
2264 @findex @code{viper-mode} | 2235 @findex @code{viper-mode} |
2265 @findex @code{vip-harness-minor-mode} | 2236 @findex @code{vip-harness-minor-mode} |
2266 @findex @code{remove-hook} | 2237 @findex @code{remove-hook} |
2267 @findex @code{add-hook} | 2238 @findex @code{add-hook} |
2279 @table @code | 2250 @table @code |
2280 @item (vip-buffer-search-enable) | 2251 @item (vip-buffer-search-enable) |
2281 @item vip-buffer-search-char nil | 2252 @item vip-buffer-search-char nil |
2282 Enable buffer search. Explicit call to @code{vip-buffer-search-enable} | 2253 Enable buffer search. Explicit call to @code{vip-buffer-search-enable} |
2283 sets @code{vip-buffer-search-char} to @kbd{g}. Alternatively, the user can | 2254 sets @code{vip-buffer-search-char} to @kbd{g}. Alternatively, the user can |
2284 set @code{vip-buffer-search-char} in @file{.vip} to a key sequence | 2255 set @code{vip-buffer-search-char} in @file{.viper} to a key sequence |
2285 to be used for buffer search. There is no need to call | 2256 to be used for buffer search. There is no need to call |
2286 @code{vip-buffer-search-enable} in that case. | 2257 @code{vip-buffer-search-enable} in that case. |
2287 @findex @code{vip-buffer-search-enable} | 2258 @findex @code{vip-buffer-search-enable} |
2288 @vindex @code{vip-buffer-search-char} | 2259 @vindex @code{vip-buffer-search-char} |
2289 @item vip-toggle-search-style | 2260 @item vip-toggle-search-style |
2303 will switch you from vanilla-style search to search via regular expressions. | 2274 will switch you from vanilla-style search to search via regular expressions. |
2304 If you hit something other than @kbd{/} after the first @kbd{/} or if the | 2275 If you hit something other than @kbd{/} after the first @kbd{/} or if the |
2305 second @kbd{/} doesn't follow quickly enough, then Viper will issue the | 2276 second @kbd{/} doesn't follow quickly enough, then Viper will issue the |
2306 usual prompt @kbd{/} and will wait for input, as usual in Vi. | 2277 usual prompt @kbd{/} and will wait for input, as usual in Vi. |
2307 If you don't like this behavior, you can ``unrecord'' these macros in your | 2278 If you don't like this behavior, you can ``unrecord'' these macros in your |
2308 @file{~/.vip} file. For instance, if you don't like the above feature, put | 2279 @file{~/.viper} file. For instance, if you don't like the above feature, put |
2309 this in @file{~/.vip}: | 2280 this in @file{~/.viper}: |
2310 @example | 2281 @example |
2311 (vip-set-vi-search-style-macros 'undefine) | 2282 (vip-set-vi-search-style-macros 'undefine) |
2312 @end example | 2283 @end example |
2313 @findex @code{vip-set-vi-search-style-macros} | 2284 @findex @code{vip-set-vi-search-style-macros} |
2314 | 2285 |
2360 paper.tex, paper.dvi. In such cases, completion will stop at the `.'. | 2331 paper.tex, paper.dvi. In such cases, completion will stop at the `.'. |
2361 If the above variable is a list of strings representing suffixes, Viper will | 2332 If the above variable is a list of strings representing suffixes, Viper will |
2362 try these suffixes | 2333 try these suffixes |
2363 in the order listed and will check if the corresponding file exists. | 2334 in the order listed and will check if the corresponding file exists. |
2364 | 2335 |
2365 For instance, if completion stopped at `paper.' and the user typed RET, | 2336 For instance, if completion stopped at `paper.' and the user typed |
2337 @key{RET}, | |
2366 then Viper will check if the files `paper.', `paper.tex', `paper.c', etc., exist. | 2338 then Viper will check if the files `paper.', `paper.tex', `paper.c', etc., exist. |
2367 It will take the first such file. If no file exists, Viper will give a chance | 2339 It will take the first such file. If no file exists, Viper will give a chance |
2368 to complete the file name by typing the appropriate suffix. If `paper.' was | 2340 to complete the file name by typing the appropriate suffix. If `paper.' was |
2369 the intended file name, hitting return will accept it. | 2341 the intended file name, hitting return will accept it. |
2370 | 2342 |
2382 the direction of older insertions, and the latter will search in | 2354 the direction of older insertions, and the latter will search in |
2383 the direction of newer insertions. Hitting @kbd{C-c M-p} or @kbd{C-c M-n} | 2355 the direction of newer insertions. Hitting @kbd{C-c M-p} or @kbd{C-c M-n} |
2384 in succession | 2356 in succession |
2385 will undo the previous insertion from the ring and insert the next item on | 2357 will undo the previous insertion from the ring and insert the next item on |
2386 the ring. If a larger ring size is needed, change the value of the above | 2358 the ring. If a larger ring size is needed, change the value of the above |
2387 variable in the @file{~/.vip} file. | 2359 variable in the @file{~/.viper} file. |
2388 | 2360 |
2389 Since typing these sequences of keys may be tedious, it is suggested that the | 2361 Since typing these sequences of keys may be tedious, it is suggested that the |
2390 user should bind a function key, such as @kbd{f31}, as follows: | 2362 user should bind a function key, such as @kbd{f31}, as follows: |
2391 @example | 2363 @example |
2392 (define-key vip-insert-global-user-map [f31] | 2364 (define-key vip-insert-global-user-map [f31] |
2457 @example | 2429 @example |
2458 (copy-face 'default 'vip-minibuffer-vi-face) | 2430 (copy-face 'default 'vip-minibuffer-vi-face) |
2459 (copy-face 'default 'vip-minibuffer-insert-face) | 2431 (copy-face 'default 'vip-minibuffer-insert-face) |
2460 (copy-face 'default 'vip-minibuffer-emacs-face) | 2432 (copy-face 'default 'vip-minibuffer-emacs-face) |
2461 @end example | 2433 @end example |
2462 in the @file{~/.vip} file. However, in that case, the user will not have any | 2434 in the @file{~/.viper} file. However, in that case, the user will not have any |
2463 indication of the current Viper state in the minibuffer. (This is important | 2435 indication of the current Viper state in the minibuffer. (This is important |
2464 if the user accidentally switches to another Viper state by typing @kbd{ESC} or | 2436 if the user accidentally switches to another Viper state by typing @key{ESC} or |
2465 @kbd{C-z}). | 2437 @kbd{C-z}). |
2466 @end table | 2438 @end table |
2467 | 2439 |
2468 @cindex Multifile documents and programs | 2440 @cindex Multifile documents and programs |
2469 | 2441 |
2693 commands are executed as you type them, so you can see precisely what is | 2665 commands are executed as you type them, so you can see precisely what is |
2694 being defined. Third, macros can be bound to arbitrary sequences of keys, | 2666 being defined. Third, macros can be bound to arbitrary sequences of keys, |
2695 not just to printable keys. For instance, one can define a macro that will | 2667 not just to printable keys. For instance, one can define a macro that will |
2696 be invoked by hitting @kbd{f3} then @kbd{f2} function keys. (The keys | 2668 be invoked by hitting @kbd{f3} then @kbd{f2} function keys. (The keys |
2697 @kbd{delete} and @kbd{backspace} are excluded; also, a macro invocation | 2669 @kbd{delete} and @kbd{backspace} are excluded; also, a macro invocation |
2698 sequence can't start with ESC. Some other keys, such as @kbd{f1} and | 2670 sequence can't start with @key{ESC}. Some other keys, such as @kbd{f1} and |
2699 @kbd{help}, can't be bound to macros under Emacs (not XEmacs), since they | 2671 @kbd{help}, can't be bound to macros under Emacs (not XEmacs), since they |
2700 are bound in @code{key-translation-map}, which overrides any other binding | 2672 are bound in @code{key-translation-map}, which overrides any other binding |
2701 the user gives to keys. In general, keys that have a binding in | 2673 the user gives to keys. In general, keys that have a binding in |
2702 @code{key-translation-map} can't be bound to a macro.) | 2674 @code{key-translation-map} can't be bound to a macro.) |
2703 | 2675 |
2717 Manual} @refill | 2689 Manual} @refill |
2718 | 2690 |
2719 When the user finishes defining a macro (which is done by typing @kbd{C-x)} --- | 2691 When the user finishes defining a macro (which is done by typing @kbd{C-x)} --- |
2720 a departure from Vi), you will be asked whether you want this | 2692 a departure from Vi), you will be asked whether you want this |
2721 macro to be global, mode-specific, or buffer-specific. You will also be | 2693 macro to be global, mode-specific, or buffer-specific. You will also be |
2722 given a chance to save the macro in your @file{~/.vip} file. | 2694 given a chance to save the macro in your @file{~/.viper} file. |
2723 This is the easiest way to save a macro and make | 2695 This is the easiest way to save a macro and make |
2724 it permanently available. If you work your startup files with bare hands, | 2696 it permanently available. If you work your startup files with bare hands, |
2725 here is how Viper saves the above macro so that it will be | 2697 here is how Viper saves the above macro so that it will be |
2726 available in Viper's Insert state (and Replace state) in buffer @code{my-buf} | 2698 available in Viper's Insert state (and Replace state) in buffer @code{my-buf} |
2727 only: | 2699 only: |
2747 keys on the keyboard. Some keys, like @kbd{\}, @kbd{ }, or digit-keys must | 2719 keys on the keyboard. Some keys, like @kbd{\}, @kbd{ }, or digit-keys must |
2748 be escaped with a backslash. Modified keys are represented as lists. For | 2720 be escaped with a backslash. Modified keys are represented as lists. For |
2749 instance, holding Meta and Control and pressing @kbd{f4} is represented as | 2721 instance, holding Meta and Control and pressing @kbd{f4} is represented as |
2750 @kbd{(control meta f4)}. | 2722 @kbd{(control meta f4)}. |
2751 If all members of a vectors are printable characters (or sequences, such as | 2723 If all members of a vectors are printable characters (or sequences, such as |
2752 @kbd{\e}, @kbd{\t}, for ESC and TAB), then they can also be represented as | 2724 @kbd{\e}, @kbd{\t}, for @key{ESC} and @key{TAB}), then they can also be represented as |
2753 strings: | 2725 strings: |
2754 | 2726 |
2755 @example | 2727 @example |
2756 (vip-record-kbd-macro "aa" 'vi-state "aaa\e" "my-buffer") | 2728 (vip-record-kbd-macro "aa" 'vi-state "aaa\e" "my-buffer") |
2757 @end example | 2729 @end example |
2766 the latter says that the macro is to be defined for all buffers | 2738 the latter says that the macro is to be defined for all buffers |
2767 (which is how macros are defined in original Vi). | 2739 (which is how macros are defined in original Vi). |
2768 | 2740 |
2769 For convenience, Viper also lets you define Vi-style macros in its Emacs | 2741 For convenience, Viper also lets you define Vi-style macros in its Emacs |
2770 state. There is no Ex command, like @kbd{:map} and @kbd{:map!} for doing | 2742 state. There is no Ex command, like @kbd{:map} and @kbd{:map!} for doing |
2771 this, but the user can include such a macro in the @file{~/.vip} file. The | 2743 this, but the user can include such a macro in the @file{~/.viper} file. The |
2772 only thing is that the @code{vip-record-kbd-macro} command should specify | 2744 only thing is that the @code{vip-record-kbd-macro} command should specify |
2773 @code{'emacs-state} instead of @code{'vi-state} or @code{'insert-state}. | 2745 @code{emacs-state} instead of @code{vi-state} or @code{insert-state}. |
2774 | 2746 |
2775 The user can get rid of a macro either by using the Ex commands @kbd{:unmap} | 2747 The user can get rid of a macro either by using the Ex commands @kbd{:unmap} |
2776 and @kbd{:unmap!} or by issuing a call to @code{vip-unrecord-kbd-macro}. | 2748 and @kbd{:unmap!} or by issuing a call to @code{vip-unrecord-kbd-macro}. |
2777 The latter is more powerful, since it can delete macros even in | 2749 The latter is more powerful, since it can delete macros even in |
2778 @code{'emacs-state}. However, @code{vip-unrecord-kbd-macro} is usually | 2750 @code{emacs-state}. However, @code{vip-unrecord-kbd-macro} is usually |
2779 needed only when the user needs to get rid of the macros that are already | 2751 needed only when the user needs to get rid of the macros that are already |
2780 predefined in Viper. | 2752 predefined in Viper. |
2781 The syntax is: | 2753 The syntax is: |
2782 @findex @code{vip-unrecord-kbd-macro} | 2754 @findex @code{vip-unrecord-kbd-macro} |
2783 @example | 2755 @example |
2784 (vip-unrecord-kbd-macro macro state) | 2756 (vip-unrecord-kbd-macro macro state) |
2785 @end example | 2757 @end example |
2786 @noindent | 2758 @noindent |
2787 The second argument must be @code{'vi-state}, @code{'insert-state}, or | 2759 The second argument must be @code{vi-state}, @code{insert-state}, or |
2788 @code{'emacs-state}. The first argument is a name of a macro. To avoid | 2760 @code{emacs-state}. The first argument is a name of a macro. To avoid |
2789 mistakes in specifying names of existing macros, type @kbd{M-x | 2761 mistakes in specifying names of existing macros, type @kbd{M-x |
2790 vip-describe-kbd-macros} and use a name from the list displayed by this | 2762 vip-describe-kbd-macros} and use a name from the list displayed by this |
2791 command. | 2763 command. |
2792 | 2764 |
2793 If an error occurs during macro definition, Emacs | 2765 If an error occurs during macro definition, Emacs |
2824 command. Under Viper, however, you may still use this key for additional | 2796 command. Under Viper, however, you may still use this key for additional |
2825 purposes, if you bind, say, a double-hitting action for that key to some | 2797 purposes, if you bind, say, a double-hitting action for that key to some |
2826 other function. Emacs doesn't allow the user to do that, but Viper does | 2798 other function. Emacs doesn't allow the user to do that, but Viper does |
2827 this through its keyboard macro facility. To do this, type @kbd{:map } | 2799 this through its keyboard macro facility. To do this, type @kbd{:map } |
2828 first. When you are asked to enter a macro name, hit f13 twice, followed by | 2800 first. When you are asked to enter a macro name, hit f13 twice, followed by |
2829 RET or SPC. | 2801 @key{RET} or @key{SPC}. |
2830 | 2802 |
2831 Emacs will now start the mapping process by actually executing | 2803 Emacs will now start the mapping process by actually executing |
2832 Vi and Emacs commands, so that you could see what will happen each time the | 2804 Vi and Emacs commands, so that you could see what will happen each time the |
2833 macro is executed. Suppose now we wanted to bind the key sequence | 2805 macro is executed. Suppose now we wanted to bind the key sequence |
2834 @kbd{f13 f13} to the command @code{eval-last-sexp}. To accomplish this, we | 2806 @kbd{f13 f13} to the command @code{eval-last-sexp}. To accomplish this, we |
2835 can type @kbd{M-x eval-last-sexp} followed by @kbd{C-x )}. | 2807 can type @kbd{M-x eval-last-sexp} followed by @kbd{C-x )}. |
2836 If you answer positively to Viper's offer to save this macro in @file{~/.vip} | 2808 If you answer positively to Viper's offer to save this macro in @file{~/.viper} |
2837 for future uses, the following will be inserted in that file: | 2809 for future uses, the following will be inserted in that file: |
2838 | 2810 |
2839 @example | 2811 @example |
2840 (vip-record-kbd-macro [f16 f16] 'vi-state | 2812 (vip-record-kbd-macro [f16 f16] 'vi-state |
2841 [(meta x) e v a l - l a s t - s e x p] | 2813 [(meta x) e v a l - l a s t - s e x p] |
2880 When defining macros using @kbd{:map} or @kbd{:map!}, the user enters the | 2852 When defining macros using @kbd{:map} or @kbd{:map!}, the user enters the |
2881 actually keys to be used to invoke the macro. For instance, you should hit | 2853 actually keys to be used to invoke the macro. For instance, you should hit |
2882 the actual key @kbd{f6} if it is to be part of a macro name; you do | 2854 the actual key @kbd{f6} if it is to be part of a macro name; you do |
2883 @emph{not} write `f 6'. When entering keys, Viper displays them as strings or | 2855 @emph{not} write `f 6'. When entering keys, Viper displays them as strings or |
2884 vectors (e.g., "abc" or [f6 f7 a]). The same holds for unmapping. Hitting | 2856 vectors (e.g., "abc" or [f6 f7 a]). The same holds for unmapping. Hitting |
2885 TAB while typing a macro name in the @kbd{:unmap} or @kbd{:unmap!} command | 2857 @key{TAB} while typing a macro name in the @kbd{:unmap} or @kbd{:unmap!} command |
2886 will cause name completion. Completions are displayed as strings or vectors. | 2858 will cause name completion. Completions are displayed as strings or vectors. |
2887 However, as before, you don't actually type ``"'', ``['', or ``]'' that | 2859 However, as before, you don't actually type ``"'', ``['', or ``]'' that |
2888 appear in the completions. These are meta-symbols that indicate whether | 2860 appear in the completions. These are meta-symbols that indicate whether |
2889 the corresponding macro name is a vector or a string. | 2861 the corresponding macro name is a vector or a string. |
2890 | 2862 |
2903 The rate at which the user must type keys in order for them to be | 2875 The rate at which the user must type keys in order for them to be |
2904 recognized as a timeout macro is controlled by the variable | 2876 recognized as a timeout macro is controlled by the variable |
2905 @code{vip-fast-keyseq-timeout}, which defaults to 200 milliseconds. | 2877 @code{vip-fast-keyseq-timeout}, which defaults to 200 milliseconds. |
2906 @vindex @code{vip-fast-keyseq-timeout} | 2878 @vindex @code{vip-fast-keyseq-timeout} |
2907 | 2879 |
2908 For the most part, Viper macros defined in @file{~/.vip} can be shared | 2880 For the most part, Viper macros defined in @file{~/.viper} can be shared |
2909 between Emacs, XEmacs, and X and TTY modes. However, macros defined via | 2881 between Emacs, XEmacs, and X and TTY modes. However, macros defined via |
2910 function keys may need separate definitions when XEmacs and Emacs have | 2882 function keys may need separate definitions when XEmacs and Emacs have |
2911 different names for the same keyboard key. For instance, the `Page Up' key | 2883 different names for the same keyboard key. For instance, the `Page Up' key |
2912 may be known in Emacs as @kbd{prior} and in XEmacs as @kbd{pgup}. | 2884 may be known in Emacs as @kbd{prior} and in XEmacs as @kbd{pgup}. |
2913 The problem with TTY may be that the function keys there generate sequences | 2885 The problem with TTY may be that the function keys there generate sequences |
2923 @findex @code{vip-describe-kbd-macros} | 2895 @findex @code{vip-describe-kbd-macros} |
2924 Finally, Viper provides a function that conveniently displays all macros | 2896 Finally, Viper provides a function that conveniently displays all macros |
2925 currently defined. To see all macros along with their definitions, type | 2897 currently defined. To see all macros along with their definitions, type |
2926 @kbd{M-x vip-describe-kbd-macros}. | 2898 @kbd{M-x vip-describe-kbd-macros}. |
2927 | 2899 |
2928 @include viper-cmd.texi | 2900 @node Commands,,Customization,Top,Top |
2901 @chapter Commands | |
2902 | |
2903 This section is a semi-automatically bowdlerized version of the Vi | |
2904 reference created by @* @samp{maart@@cs.vu.nl} and others. It can be | |
2905 found on the Vi archives. This reference has been adapted for Viper.@refill | |
2906 | |
2907 @menu | |
2908 * Groundwork:: Textual Conventions and Viper basics | |
2909 * Text Handling:: Moving, Editing, Undoing. | |
2910 * Display:: Scrolling. | |
2911 * File and Buffer Handling:: Editing, Writing and Quitting. | |
2912 * Mapping:: Mapping Keys, Keyboard Macros | |
2913 * Shell Commands:: Accessing Shell Commands, Processing Text | |
2914 * Options:: Ex options, the @kbd{:set} commands | |
2915 * Emacs Related Commands:: Meta Keys, Windows | |
2916 * Mouse-bound Commands:: Search and insertion of text | |
2917 @end menu | |
2918 | |
2919 @node Groundwork, Text Handling, Commands, Commands | |
2920 @comment node-name, next, previous, up | |
2921 @section Groundwork | |
2922 | |
2923 The VI command set is based on the idea of combining motion commands | |
2924 with other commands. The motion command is used as a text region | |
2925 specifier for other commands. | |
2926 We classify motion commands into @dfn{point commands} and | |
2927 @dfn{line commands}.@refill | |
2928 | |
2929 @cindex point commands | |
2930 | |
2931 The point commands are: | |
2932 | |
2933 @quotation | |
2934 @kbd{h}, @kbd{l}, @kbd{0}, @kbd{$}, @kbd{w}, @kbd{W}, @kbd{b}, @kbd{B}, | |
2935 @kbd{e}, @kbd{E}, @kbd{(}, @kbd{)}, @kbd{/}, @kbd{?}, @kbd{`}, @kbd{f}, | |
2936 @kbd{F}, @kbd{t}, @kbd{T}, @kbd{%}, @kbd{;}, @kbd{,}, @kbd{^} | |
2937 @end quotation | |
2938 | |
2939 @cindex line commands | |
2940 | |
2941 The line commands are: | |
2942 | |
2943 @quotation | |
2944 @kbd{j}, @kbd{k}, @kbd{+}, @kbd{-}, @kbd{H}, @kbd{M}, @kbd{L}, @kbd{@{}, | |
2945 @kbd{@}}, @kbd{G}, @kbd{'}, @kbd{[[}, @kbd{]]}, @kbd{[]} | |
2946 @end quotation | |
2947 @noindent | |
2948 | |
2949 Text Deletion Commands (@xref{Deleting Text}), Change commands | |
2950 (@xref{Changing Text}), even Shell Commands (@xref{Shell Commands}) | |
2951 use these commands to describe a region of text to operate on. | |
2952 | |
2953 @cindex r and R region specifiers | |
2954 | |
2955 Viper adds two region descriptors, @kbd{r} and @kbd{R}. These describe | |
2956 the Emacs regions (@xref{Basics}), but they are not movement commands. | |
2957 | |
2958 The command description uses angle brackets @samp{<>} to indicate | |
2959 metasyntactic variables, since the normal conventions of using simple | |
2960 text can be confusing with Viper where the commands themselves are | |
2961 characters. Watch out where @kbd{<} shift commands and @kbd{<count>} are | |
2962 mentioned together!!! | |
2963 | |
2964 @kindex <move> | |
2965 @kindex <a-z> | |
2966 @kindex <address> | |
2967 @cindex <move> | |
2968 @cindex <a-z> | |
2969 @cindex <address> | |
2970 @cindex movements | |
2971 | |
2972 @samp{<move>} refers to the above movement commands, and @samp{<a-z>} | |
2973 refers to registers or textmarkers from @samp{a} to @samp{z}. Note | |
2974 that the @samp{<move>} is described by full move commands, that is to | |
2975 say they will take counts, and otherwise behave like normal move commands. | |
2976 @cindex Ex addresses | |
2977 @samp{<address>} refers to Ex line addresses, which include | |
2978 | |
2979 @table @kbd | |
2980 @item . <No address> | |
2981 Current line | |
2982 @item .+n .-n | |
2983 Add or subtract for current line | |
2984 @item number | |
2985 Actual line number, use @kbd{.=} to get the line number | |
2986 @item '<a-z> | |
2987 Textmarker | |
2988 @item $ | |
2989 Last line | |
2990 @item x,y | |
2991 Where x and y are one of the above | |
2992 @item % | |
2993 @cindex % (Ex address) | |
2994 For the whole file, same as (1,$). | |
2995 @item /pat/ | |
2996 @item ?pat? | |
2997 Next or previous line with pattern pat | |
2998 @end table | |
2999 | |
3000 @cindex % (Current file) | |
3001 Note that @samp{%} is used in Ex commands to mean current file. If you | |
3002 want a @samp{%} in your command, it must be escaped as @samp{\%}. | |
3003 @cindex # (Previous file) | |
3004 Similarly, @samp{#} expands to the previous file. The previous file is | |
3005 the first file in @kbd{:args} listing. This defaults to previous window | |
3006 in the VI sense if you have one window only. | |
3007 | |
3008 @kindex <args> | |
3009 @kindex <cmd> | |
3010 @cindex <args> | |
3011 @cindex <cmd> | |
3012 @noindent | |
3013 Others like @samp{<args> -- arguments}, @samp{<cmd> -- command} etc. | |
3014 should be fairly obvious. | |
3015 | |
3016 @noindent | |
3017 Common characters referred to include: | |
3018 | |
3019 @table @kbd | |
3020 @item <sp> | |
3021 Space | |
3022 @item <ht> | |
3023 Tab | |
3024 @item <lf> | |
3025 Linefeed | |
3026 @item <esc> | |
3027 Escape | |
3028 @item <cr> | |
3029 Return, Enter | |
3030 @end table | |
3031 @cindex <cr> | |
3032 @cindex <esc> | |
3033 @cindex <lf> | |
3034 @cindex <ht> | |
3035 @cindex <sp> | |
3036 | |
3037 @cindex words | |
3038 @cindex WORDS | |
3039 @cindex char | |
3040 @cindex CHAR | |
3041 | |
3042 We also use @samp{word} for alphanumeric/non-alphanumeric words, and | |
3043 @samp{WORD} for whitespace delimited words. @samp{char} refers to any | |
3044 ASCII character, @samp{CHAR} to non-whitespace character. | |
3045 Brackets @samp{[]} indicate optional parameters; @samp{<count>} also | |
3046 optional, usually defaulting to 1. Brackets are elided for | |
3047 @samp{<count>} to eschew obfuscation. | |
3048 | |
3049 Viper's idea of Vi's words is slightly different from Vi. First, Viper | |
3050 words understand Emacs symbol tables. Therefore, all symbols declared to be | |
3051 alphanumeric in a symbol table can automatically be made part of the Viper | |
3052 word. This is useful when, for instance, editing text containing European, | |
3053 Cyrillic, etc., letters. | |
3054 | |
3055 Second, Viper lets you depart from Vi's idea of a word by changing the | |
3056 value of @code{vip-syntax-preference}. By default, this variable is set to | |
3057 @code{strict-vi}, which means that alphanumeric symbols are exactly as | |
3058 in Vi. | |
3059 However, if the value is @code{reformed-vi} then alphanumeric | |
3060 symbols will be those specified by the current Emacs syntax table (which | |
3061 may be different for different major modes) plus the underscore symbol | |
3062 @code{_}. The user can also specify the value @code{emacs}, which would | |
3063 make Viper use exactly the Emacs notion of word. In particular, the | |
3064 underscore may not be part of a word. Finally, if | |
3065 @code{vip-syntax-preference} is set to @code{extended}, Viper words would | |
3066 consist of characters that are classified as alphanumeric @emph{or} as | |
3067 parts of symbols. This is convenient for writing programs and in many other | |
3068 situations. | |
3069 | |
3070 @vindex @code{vip-syntax-preference} | |
3071 @cindex syntax table | |
3072 | |
3073 @code{vip-syntax-preference} is a local variable, so it can have different | |
3074 values for different major modes. For instance, in programming modes it can | |
3075 have the value @code{extended}. In text modes where words contain special | |
3076 characters, such as European (non-English) letters, Cyrillic letters, etc., | |
3077 the value can be @code{reformed-vi} or @code{emacs}. | |
3078 | |
3079 Changes to @code{vip-syntax-preference} should be done in the hooks to | |
3080 various major modes. Furthermore, for these changes to take effect, you | |
3081 should execute @code{(vip-update-alphanumeric-class)} right after changing | |
3082 the value of @code{vip-syntax-preference}. | |
3083 | |
3084 The above discussion concerns only the movement commands. In regular | |
3085 expressions, words remain the same as in Emacs. That is, the expressions | |
3086 @code{\w}, @code{\>}, @code{\<}, etc., use Emacs' idea of what is a word, | |
3087 and they don't look into the value of variable | |
3088 @code{vip-syntax-preference}. This is because Viper doesn't change syntax | |
3089 tables in order to not thwart the various major modes that set these | |
3090 tables. | |
3091 | |
3092 The usual Emacs convention is used to indicate Control Characters, i.e | |
3093 C-h for Control-h. @emph{Do not confuse this to mean the separate | |
3094 characters C - h!!!} The @kbd{^} is itself, never used to indicate a | |
3095 Control character. | |
3096 | |
3097 @node Text Handling, Display, Groundwork, Commands | |
3098 @section Text Handling | |
3099 | |
3100 @menu | |
3101 * Move Commands:: Moving, Searching | |
3102 * Marking:: Textmarkers in Viper and the Emacs Mark. | |
3103 * Appending Text:: Text insertion, Shifting, Putting | |
3104 * Editing in Insert State:: Autoindent, Quoting etc. | |
3105 * Deleting Text:: Deleting | |
3106 * Changing Text:: Changing, Replacement, Joining | |
3107 * Search and Replace:: Searches, Query Replace, Pattern Commands | |
3108 * Yanking:: Yanking, Viewing Registers | |
3109 * Undoing:: Multiple Undo, Backups | |
3110 @end menu | |
3111 | |
3112 @node Move Commands,Marking,,Text Handling | |
3113 @subsection Move Commands | |
3114 | |
3115 @cindex movement commands | |
3116 @cindex searching | |
3117 @cindex textmarkers | |
3118 @cindex markers | |
3119 @cindex column movement | |
3120 @cindex paragraphs | |
3121 @cindex headings | |
3122 @cindex sections | |
3123 @cindex sentences | |
3124 @cindex matching parens | |
3125 @cindex paren matching | |
3126 | |
3127 @table @kbd | |
3128 @item <count> h C-h | |
3129 <count> chars to the left. | |
3130 @item <count> j <lf> C-n | |
3131 <count> lines downward. | |
3132 @item <count> l <sp> | |
3133 <count> chars to the right. | |
3134 @item <count> k C-p | |
3135 <count> lines upward. | |
3136 @item <count> $ | |
3137 To the end of line <count> from the cursor. | |
3138 @item <count> ^ | |
3139 To the first CHAR <count> - 1 lines lower. | |
3140 @item <count> - | |
3141 To the first CHAR <count> lines higher. | |
3142 @item <count> + <cr> | |
3143 To the first CHAR <count> lines lower. | |
3144 @item 0 | |
3145 To the first char of the line. | |
3146 @item <count> | | |
3147 To column <count> | |
3148 @item <count> f<char> | |
3149 <count> <char>s to the right (find). | |
3150 @item <count> t<char> | |
3151 Till before <count> <char>s to the right. | |
3152 @item <count> F<char> | |
3153 <count> <char>s to the left. | |
3154 @item <count> T<char> | |
3155 Till after <count> <char>s to the left. | |
3156 @item <count> ; | |
3157 Repeat latest @kbd{f t F T} <count> times. | |
3158 @item <count> , | |
3159 Repeat latest @kbd{f t F T} | |
3160 <count> times in opposite direction. | |
3161 @item <count> w | |
3162 <count> words forward. | |
3163 @item <count> W | |
3164 <count> WORDS forward. | |
3165 @item <count> b | |
3166 <count> words backward. | |
3167 @item <count> B | |
3168 <count> WORDS backward. | |
3169 @item <count> e | |
3170 To the end of word <count> forward. | |
3171 @item <count> E | |
3172 To the end of WORD <count> forward. | |
3173 @item <count> G | |
3174 Go to line <count> (default end-of-file). | |
3175 @item <count> H | |
3176 To line <count> from top of the screen (home). | |
3177 @item <count> L | |
3178 To line <count> from bottom of the screen (last). | |
3179 @item M | |
3180 To the middle line of the screen. | |
3181 @item <count> ) | |
3182 <count> sentences forward. | |
3183 @item <count> ( | |
3184 <count> sentences backward. | |
3185 @item <count> @} | |
3186 <count> paragraphs forward. | |
3187 @item <count> @{ | |
3188 <count> paragraphs backward. | |
3189 @item <count> ]] | |
3190 To the <count>th heading. | |
3191 @item <count> [[ | |
3192 To the <count>th previous heading. | |
3193 @item <count> [] | |
3194 To the end of <count>th heading. | |
3195 @item m<a-z> | |
3196 Mark the cursor position with a letter. | |
3197 @item `<a-z> | |
3198 To the mark. | |
3199 @item '<a-z> | |
3200 To the first CHAR of the line with the mark. | |
3201 @item [<a-z> | |
3202 Show contents of textmarker. | |
3203 @item ]<a-z> | |
3204 Show contents of register. | |
3205 @item `` | |
3206 To the cursor position before the latest absolute | |
3207 jump (of which are examples @kbd{/} and @kbd{G}). | |
3208 @item '' | |
3209 To the first CHAR of the line on which the cursor | |
3210 was placed before the latest absolute jump. | |
3211 @item <count> /<string> | |
3212 To the <count>th occurrence of <string>. | |
3213 @item <count> /<cr> | |
3214 To the <count>th occurrence of <string> from previous @kbd{/ or ?}. | |
3215 @item <count> ?<string> | |
3216 To the <count>th previous occurrence of <string>. | |
3217 @item <count> ?<cr> | |
3218 To the <count>th previous occurrence of <string> from previous @kbd{? or /}. | |
3219 @item n | |
3220 Repeat latest @kbd{/} @kbd{?} (next). | |
3221 @item N | |
3222 Repeat latest search in opposite direction. | |
3223 @item C-c / | |
3224 Without a prefix argument, this command toggles | |
3225 case-sensitive/case-insensitive search modes and plain vanilla/regular | |
3226 expression search. With the prefix argument 1, i.e., | |
3227 @kbd{1 C-c /}, this toggles case-sensitivity; with the prefix argument 2, | |
3228 toggles plain vanilla search and search using | |
3229 regular expressions. @xref{Viper Specials}, for alternative ways to invoke | |
3230 this function. | |
3231 @cindex vanilla search | |
3232 @cindex case-sensitive search | |
3233 @cindex case-insensitive search | |
3234 @item % | |
3235 Find the next bracket/parenthesis/brace and go to its match. | |
3236 By default, Viper ignores brackets/parentheses/braces that occur inside | |
3237 parentheses. You can change this by setting | |
3238 @code{vip-parse-sexp-ignore-comments} to nil in your @file{.viper} fipe. | |
3239 This option can also be toggled interactively if you quickly hit @kbd{%} | |
3240 three times. | |
3241 @end table | |
3242 @kindex @kbd{%} | |
3243 @kindex @kbd{C-c /} | |
3244 @kindex @kbd{N} | |
3245 @kindex @kbd{n} | |
3246 @kindex @kbd{?<cr>} | |
3247 @kindex @kbd{/<cr>} | |
3248 @kindex @kbd{?<string>} | |
3249 @kindex @kbd{/<string>} | |
3250 @kindex @kbd{''} | |
3251 @kindex @kbd{``} | |
3252 @kindex @kbd{]<a-z>} | |
3253 @kindex @kbd{[<a-z>} | |
3254 @kindex @kbd{'<a-z>} | |
3255 @kindex @kbd{`<a-z>} | |
3256 @kindex @kbd{m<a-z>} | |
3257 @kindex @kbd{[]} | |
3258 @kindex @kbd{[[} | |
3259 @kindex @kbd{]]} | |
3260 @kindex @kbd{@{} | |
3261 @kindex @kbd{@}} | |
3262 @kindex @kbd{(} | |
3263 @kindex @kbd{)} | |
3264 @kindex @kbd{M} | |
3265 @kindex @kbd{L} | |
3266 @kindex @kbd{H} | |
3267 @kindex @kbd{G} | |
3268 @kindex @kbd{E} | |
3269 @kindex @kbd{e} | |
3270 @kindex @kbd{B} | |
3271 @kindex @kbd{b} | |
3272 @kindex @kbd{W} | |
3273 @kindex @kbd{w} | |
3274 @kindex @kbd{,} | |
3275 @kindex @kbd{;} | |
3276 @kindex @kbd{T<char>} | |
3277 @kindex @kbd{F<char>} | |
3278 @kindex @kbd{t<char>} | |
3279 @kindex @kbd{f<char>} | |
3280 @kindex @kbd{|} | |
3281 @kindex @kbd{0} | |
3282 @kindex @kbd{<cr>} | |
3283 @kindex @kbd{+} | |
3284 @kindex @kbd{-} | |
3285 @kindex @kbd{^} | |
3286 @kindex @kbd{$} | |
3287 @kindex @kbd{C-p} | |
3288 @kindex @kbd{<lf>} | |
3289 @kindex @kbd{<sp>} | |
3290 @kindex @kbd{C-n} | |
3291 @kindex @kbd{C-h} | |
3292 @kindex @kbd{h} | |
3293 @kindex @kbd{j} | |
3294 @kindex @kbd{k} | |
3295 @kindex @kbd{l} | |
3296 @vindex @code{vip-parse-sexp-ignore-comments} | |
3297 | |
3298 @node Marking,Appending Text,Move Commands,Text Handling | |
3299 @subsection Marking | |
3300 | |
3301 Emacs mark is referred to in the region specifiers @kbd{r} and @kbd{R}. | |
3302 @xref{Emacs Preliminaries} and @pxref{Basics} for explanation. Also | |
3303 see @ref{Mark,,Mark,emacs,The GNU Emacs manual}, for an explanation of | |
3304 the Emacs mark ring. | |
3305 | |
3306 @cindex marking | |
3307 | |
3308 @table @kbd | |
3309 @item m<a-z> | |
3310 Mark the current file and position with the specified letter. | |
3311 @item m . | |
3312 Set the Emacs mark (@xref{Emacs Preliminaries}) at point. | |
3313 @item m < | |
3314 Set the Emacs mark at beginning of buffer. | |
3315 @item m > | |
3316 Set the Emacs mark at end of buffer. | |
3317 @item m , | |
3318 Jump to the Emacs mark. | |
3319 @item :mark <char> | |
3320 Mark position with text marker named <char>. This is an Ex command. | |
3321 @item :k <char> | |
3322 Same as @kbd{:mark}. | |
3323 @item `` | |
3324 Exchange point and mark. | |
3325 @item '' | |
3326 Exchange point and mark and go to the first CHAR on line. | |
3327 @item '<a-z> | |
3328 Go to specified Viper mark. | |
3329 @item | |
3330 Go to specified Viper mark and go to the first CHAR on line. | |
3331 @end table | |
3332 @kindex @kbd{m<a-z>} | |
3333 @kindex @kbd{m.} | |
3334 @kindex @kbd{m>} | |
3335 @kindex @kbd{m<} | |
3336 @kindex @kbd{m,} | |
3337 @findex @kbd{:mark} | |
3338 @findex @kbd{:k} | |
3339 @kindex @kbd{''} | |
3340 @kindex @kbd{``} | |
3341 @kindex @kbd{`<a-z>} | |
3342 @kindex @kbd{'<a-z>} | |
3343 | |
3344 @node Appending Text, Editing in Insert State, Marking,Text Handling | |
3345 @subsection Appending Text | |
3346 | |
3347 @xref{Options} to see how to change tab and shiftwidth size. See the GNU | |
3348 Emacs manual, or try @kbd{C-ha tabs} (If you have turned Emacs help on). | |
3349 Check out the variable @code{indent-tabs-mode} to put in just spaces. | |
3350 Also see options for word-wrap. | |
3351 | |
3352 @cindex inserting | |
3353 @cindex appending | |
3354 @cindex paste | |
3355 @cindex put | |
3356 | |
3357 @table @kbd | |
3358 @item <count> a | |
3359 <count> times after the cursor. | |
3360 @item <count> A | |
3361 <count> times at the end of line. | |
3362 @item <count> i | |
3363 <count> times before the cursor (insert). | |
3364 @item <count> I | |
3365 <count> times before the first CHAR of the line | |
3366 @item <count> o | |
3367 On a new line below the current (open). | |
3368 The count is only useful on a slow terminal. | |
3369 @item <count> O | |
3370 On a new line above the current. | |
3371 The count is only useful on a slow terminal. | |
3372 @item <count> ><move> | |
3373 Shift the lines described by <count><move> one | |
3374 shiftwidth to the right (layout!). | |
3375 @item <count> >> | |
3376 Shift <count> lines one shiftwidth to the right. | |
3377 @item <count> ["<a-z1-9>]p | |
3378 Put the contents of the (default undo) buffer | |
3379 <count> times after the cursor. The register will | |
3380 be automatically downcased. | |
3381 @item <count> ["<a-z1-9>]P | |
3382 Put the contents of the (default undo) buffer | |
3383 <count> times before the cursor. The register will | |
3384 @item [<a-z> | |
3385 Show contents of textmarker. | |
3386 @item ]<a-z> | |
3387 Show contents of register. | |
3388 @item <count> . | |
3389 Repeat previous command <count> times. For destructive | |
3390 commands as well as undo. | |
3391 @item f1 1 and f1 2 | |
3392 While @kbd{.} repeats the last destructive command, | |
3393 these two macros repeat the second-last and the third-last destructive | |
3394 commands. @xref{Vi Macros}, for more information on Vi macros. | |
3395 @item C-c M-p and C-c M-n | |
3396 In Vi state, | |
3397 these commands help peruse the history of Vi's destructive commands. | |
3398 Successive typing of @kbd{C-c M-p} causes Viper to search the history in | |
3399 the direction | |
3400 of older commands, while hitting @kbd{C-c M-n} does so in reverse | |
3401 order. Each command in the history is displayed in the Minibuffer. The | |
3402 displayed command can | |
3403 then be executed by typing `@kbd{.}'. | |
3404 | |
3405 Since typing the above sequences of keys may be tedious, the | |
3406 functions doing the perusing can be bound to unused keyboard keys in the | |
3407 @file{~/.viper} file. @xref{Viper Specials}, for details. | |
3408 @end table | |
3409 @kindex @kbd{C-c M-p} | |
3410 @kindex @kbd{C-c M-n} | |
3411 @kindex @kbd{.} | |
3412 @kindex @kbd{]<a-z>} | |
3413 @kindex @kbd{[<a-z>} | |
3414 @kindex @kbd{P} | |
3415 @kindex @kbd{p} | |
3416 @kindex @kbd{"<a-z1-9>p} | |
3417 @kindex @kbd{"<a-z1-9>P} | |
3418 @kindex @kbd{>>} | |
3419 @kindex @kbd{><move>} | |
3420 @kindex @kbd{O} | |
3421 @kindex @kbd{o} | |
3422 @kindex @kbd{i} | |
3423 @kindex @kbd{A} | |
3424 @kindex @kbd{a} | |
3425 | |
3426 @node Editing in Insert State, Deleting Text, Appending Text,Text Handling | |
3427 @subsection Editing in Insert State | |
3428 | |
3429 Minibuffer can be edited similarly to Insert state, and you can switch | |
3430 between Insert/Replace/Vi states at will. | |
3431 Some users prefer plain Emacs feel in the Minibuffer. To this end, set | |
3432 @var{vip-vi-style-in-minibuffer} to @code{nil}. | |
3433 | |
3434 @cindex Insert state | |
3435 | |
3436 @table @kbd | |
3437 @item C-v | |
3438 Deprive the next char of its special meaning (quoting). | |
3439 @item C-h | |
3440 One char back. | |
3441 @item C-w | |
3442 One word back. | |
3443 @item C-u | |
3444 Back to the begin of the change on the | |
3445 current line. | |
3446 | |
3447 @end table | |
3448 @kindex @kbd{C-u} | |
3449 @kindex @kbd{C-w} | |
3450 @kindex @kbd{C-v} | |
3451 | |
3452 @node Deleting Text, Changing Text, Editing in Insert State, Text Handling | |
3453 @subsection Deleting Text | |
3454 | |
3455 | |
3456 There is one difference in text deletion that you should be | |
3457 aware of. This difference comes from Emacs and was adopted in Viper | |
3458 because we find it very useful. In Vi, if you delete a line, say, and then | |
3459 another line, these two deletions are separated and are put back | |
3460 separately if you use the @samp{p} command. In Emacs (and Viper), successive | |
3461 series of deletions that are @emph{not interrupted} by other commands are | |
3462 lumped together, so the deleted text gets accumulated and can be put back | |
3463 as one chunk. If you want to break a sequence of deletions so that the | |
3464 newly deleted text could be put back separately from the previously deleted | |
3465 text, you should perform a non-deleting action, e.g., move the cursor one | |
3466 character in any direction. | |
3467 | |
3468 @cindex shifting text | |
3469 | |
3470 @table @kbd | |
3471 @item <count> x | |
3472 Delete <count> chars under and after the cursor. | |
3473 @item <count> X | |
3474 Delete <count> chars before the cursor. | |
3475 @item <count> d<move> | |
3476 Delete from point to endpoint of <count><move>. | |
3477 @item <count> dd | |
3478 Delete <count> lines. | |
3479 @item D | |
3480 The rest of the line. | |
3481 @item <count> <<move> | |
3482 Shift the lines described by <count><move> one | |
3483 shiftwidth to the left (layout!). | |
3484 @item <count> << | |
3485 Shift <count> lines one shiftwidth to the left. | |
3486 @end table | |
3487 @kindex @kbd{<<} | |
3488 @kindex @kbd{<<move>} | |
3489 @kindex @kbd{D} | |
3490 @kindex @kbd{dd} | |
3491 @kindex @kbd{d<move>} | |
3492 @kindex @kbd{X} | |
3493 @kindex @kbd{x} | |
3494 | |
3495 @node Changing Text, Search and Replace, Deleting Text,Text Handling | |
3496 @subsection Changing Text | |
3497 | |
3498 @cindex joining lines | |
3499 @cindex changing case | |
3500 @cindex quoting regions | |
3501 @cindex substitution | |
3502 | |
3503 @table @kbd | |
3504 @item <count> r<char> | |
3505 Replace <count> chars by <char> - no <esc>. | |
3506 @item <count> R | |
3507 Overwrite the rest of the line, | |
3508 appending change @var{count - 1} times. | |
3509 @item <count> s | |
3510 Substitute <count> chars. | |
3511 @item <count> S | |
3512 Change <count> lines. | |
3513 @item <count> c<move> | |
3514 Change from begin to endpoint of <count><move>. | |
3515 @item <count> cc | |
3516 Change <count> lines. | |
3517 @item <count> C | |
3518 The rest of the line and <count> - 1 next lines. | |
3519 @item <count> =<move> | |
3520 Reindent the region described by move. | |
3521 @item <count> ~ | |
3522 Switch lower and upper cases. | |
3523 @item <count> J | |
3524 Join <count> lines (default 2). | |
3525 @item :[x,y]s/<p>/<r>/<f> | |
3526 Substitute (on lines x through y) the pattern | |
3527 <p> (default the last pattern) with <r>. Useful | |
3528 flags <f> are @samp{g} for @samp{global} (i.e. change every | |
3529 non-overlapping occurrence of <p>) and @samp{c} for | |
3530 @samp{confirm} (type @samp{y} to confirm a particular | |
3531 substitution, else @samp{n} ). Instead of @kbd{/} any | |
3532 punctuation CHAR unequal to <space> <tab> and <lf> can be used as | |
3533 delimiter. | |
3534 @item :[x,y]copy [z] | |
3535 Copy text between @kbd{x} and @kbd{y} to the position after @kbd{z}. | |
3536 @item :[x,y]t [z] | |
3537 Same as @kbd{:copy}. | |
3538 @item :[x,y]move [z] | |
3539 Move text between @kbd{x} and @kbd{y} to the position after @kbd{z}. | |
3540 @item & | |
3541 Repeat latest Ex substitute command, e.g. | |
3542 @kbd{:s/wrong/good}. | |
3543 @item C-c / | |
3544 Toggle case-sensitive search. With prefix argument, toggle vanilla/regular | |
3545 expression search. | |
3546 @item #c<move> | |
3547 Change upper-case characters in the region to lower-case. | |
3548 @item #C<move> | |
3549 Change lower-case characters in the region to upper-case. | |
3550 @item #q<move> | |
3551 Insert specified string at the beginning of each line in the region | |
3552 @item C-c M-p and C-c M-n | |
3553 In Insert and Replace states, these keys are bound to commands that peruse | |
3554 the history of the text | |
3555 previously inserted in other insert or replace commands. By repeatedly typing | |
3556 @kbd{C-c M-p} or @kbd{C-c M-n}, you will cause Viper to | |
3557 insert these previously used strings one by one. | |
3558 When a new string is inserted, the previous one is deleted. | |
3559 | |
3560 In Vi state, these keys are bound to functions that peruse the history of | |
3561 destructive Vi commands. | |
3562 @xref{Viper Specials}, for details. | |
3563 @end table | |
3564 @kindex @kbd{C-c M-p} | |
3565 @kindex @kbd{C-c M-n} | |
3566 @kindex @kbd{#q<move> } | |
3567 @kindex @kbd{#C<move>} | |
3568 @kindex @kbd{#c<move>} | |
3569 @kindex @kbd{&} | |
3570 @findex @kbd{:substitute/<p>/<r>/<f>} | |
3571 @findex @kbd{:s/<p>/<r>/<f>} | |
3572 @findex @kbd{:copy [z]} | |
3573 @findex @kbd{:t [z]} | |
3574 @findex @kbd{:move [z]} | |
3575 @kindex @kbd{J} | |
3576 @kindex @kbd{~} | |
3577 @kindex @kbd{=<move>} | |
3578 @kindex @kbd{C} | |
3579 @kindex @kbd{cc} | |
3580 @kindex @kbd{c<move>} | |
3581 @kindex @kbd{S} | |
3582 @kindex @kbd{s} | |
3583 @kindex @kbd{R} | |
3584 @kindex @kbd{r<char>} | |
3585 | |
3586 @node Search and Replace, Yanking, Changing Text,Text Handling | |
3587 @subsection Search and Replace | |
3588 | |
3589 @xref{Groundwork}, for Ex address syntax. @xref{Options} to see how to | |
3590 get literal (non-regular-expression) search and how to stop search from | |
3591 wrapping around. | |
3592 | |
3593 @table @kbd | |
3594 @item <count> /<string> | |
3595 To the <count>th occurrence of <string>. | |
3596 @item <count> ?<string> | |
3597 To the <count>th previous occurrence of <string>. | |
3598 @item <count> g<move> | |
3599 Search for the text described by move. (off by default) | |
3600 @item n | |
3601 Repeat latest @kbd{/} @kbd{?} (next). | |
3602 @item N | |
3603 Idem in opposite direction. | |
3604 @item % | |
3605 Find the next bracket and go to its match | |
3606 @item :[x,y]g/<string>/<cmd> | |
3607 @cindex text processing | |
3608 Search globally [from line x to y] for <string> | |
3609 and execute the Ex <cmd> on each occurrence. | |
3610 @item :[x,y]v/<string>/<cmd> | |
3611 Execute <cmd> on the lines that don't match. | |
3612 @item #g<move> | |
3613 Execute the last keyboard macro for each line in the region. | |
3614 @xref{Macros and Registers}, for more info. | |
3615 @item Q | |
3616 Query Replace. | |
3617 @item :ta <name> | |
3618 Search in the tags file where <name> is defined (file, line), and go to it. | |
3619 @item :[x,y]s/<p>/<r>/<f> | |
3620 Substitute (on lines x through y) the pattern <p> (default the last | |
3621 pattern) with <r>. Useful | |
3622 flags <f> are @samp{g} for @samp{global} (i.e. change every | |
3623 non-overlapping occurrence of <p>) and @samp{c} for | |
3624 @samp{confirm} (type @samp{y} to confirm a particular | |
3625 substitution, else @samp{n}). Instead of @kbd{/} any | |
3626 punctuation CHAR unequal to <space> <tab> and <lf> can be used as delimiter. | |
3627 @item & | |
3628 Repeat latest Ex substitute command, e.g. @kbd{:s/wrong/good}. | |
3629 @end table | |
3630 @kindex @kbd{&} | |
3631 @findex @kbd{:substitute/<p>/<r>/<f>} | |
3632 @kindex @kbd{Q} | |
3633 @kindex @kbd{#g<move>} | |
3634 @findex @kbd{:v/<string>/<cmd>} | |
3635 @findex @kbd{:g/<string>/<cmd>} | |
3636 @findex @kbd{:global/<string>/<cmd>} | |
3637 @findex @kbd{:tag <name>} | |
3638 @kindex @kbd{%} | |
3639 @kindex @kbd{N} | |
3640 @kindex @kbd{n} | |
3641 @kindex @kbd{g<move>} | |
3642 @kindex @kbd{?<string>} | |
3643 @kindex @kbd{/<string>} | |
3644 | |
3645 @node Yanking,Undoing,Search and Replace,Text Handling | |
3646 @subsection Yanking | |
3647 | |
3648 @cindex cut and paste | |
3649 @cindex paste | |
3650 | |
3651 @table @kbd | |
3652 @item <count> y<move> | |
3653 Yank from begin to endpoint of <count><move>. | |
3654 @item <count> "<a-z>y<move> | |
3655 Yank from begin to endpoint of <count><move> to register. | |
3656 @item <count> "<A-Z>y<move> | |
3657 Yank from begin to endpoint of <count><move> and append | |
3658 to register. | |
3659 @item <count> yy | |
3660 <count> lines. | |
3661 @item <count> Y | |
3662 Idem (should be equivalent to @kbd{y$} though). | |
3663 @item m<a-z> | |
3664 Mark the cursor position with a letter. | |
3665 @item [<a-z> | |
3666 Show contents of textmarker. | |
3667 @item ]<a-z> | |
3668 Show contents of register. | |
3669 @item <count> ["<a-z1-9>]p | |
3670 Put the contents of the (default undo) buffer | |
3671 <count> times after the cursor. The register will | |
3672 be automatically downcased. | |
3673 @item <count> ["<a-z1-9>]P | |
3674 Put the contents of the (default undo) buffer | |
3675 <count> times before the cursor. The register will | |
3676 @end table | |
3677 @kindex @kbd{P} | |
3678 @kindex @kbd{p} | |
3679 @kindex @kbd{"<a-z1-9>p} | |
3680 @kindex @kbd{"<a-z1-9>P} | |
3681 @kindex @kbd{]<a-z>} | |
3682 @kindex @kbd{[<a-z>} | |
3683 @kindex @kbd{m<a-z>} | |
3684 @kindex @kbd{Y} | |
3685 @kindex @kbd{yy} | |
3686 @kindex @kbd{"<A-Z>y<move>} | |
3687 @kindex @kbd{"<a-z>y<move>} | |
3688 @kindex @kbd{y<move>} | |
3689 @kindex @kbd{yank} | |
3690 @findex @kbd{:yank} | |
3691 | |
3692 @node Undoing,, Yanking,Text Handling | |
3693 @subsection Undoing | |
3694 | |
3695 @cindex undo | |
3696 @cindex backup files | |
3697 | |
3698 @table @kbd | |
3699 @item u U | |
3700 Undo the latest change. | |
3701 @item . | |
3702 Repeat undo. | |
3703 @item :q! | |
3704 Quit Vi without writing. | |
3705 @item :e! | |
3706 Re-edit a messed-up file. | |
3707 @item :rec | |
3708 Recover file from autosave. Viper also creates backup files | |
3709 that have a @samp{~} appended to them. | |
3710 @end table | |
3711 @findex @kbd{:rec} | |
3712 @findex @kbd{:e!} | |
3713 @findex @kbd{:q!} | |
3714 @kindex @kbd{.} | |
3715 @kindex @kbd{U} | |
3716 @kindex @kbd{u} | |
3717 | |
3718 @node Display, File and Buffer Handling, Text Handling, Commands | |
3719 @section Display | |
3720 | |
3721 @cindex scrolling | |
3722 | |
3723 @table @kbd | |
3724 @item C-g | |
3725 At user level 1, | |
3726 give file name, status, current line number | |
3727 and relative position. @* | |
3728 At user levels 2 and higher, abort the current command. | |
3729 @item C-c g | |
3730 Give file name, status, current line number and relative position -- all | |
3731 user levels. | |
3732 @item C-l | |
3733 Refresh the screen. | |
3734 @item <count> C-e | |
3735 Expose <count> more lines at bottom, cursor stays put (if possible). | |
3736 @item <count> C-y | |
3737 Expose <count> more lines at top, cursor stays put (if possible). | |
3738 @item <count> C-d | |
3739 Scroll <count> lines downward (default the number of the previous scroll; | |
3740 initialization: half a page). | |
3741 @item <count> C-u | |
3742 Scroll <count> lines upward (default the number of the previous scroll; | |
3743 initialization: half a page). | |
3744 @item <count> C-f | |
3745 <count> pages forward. | |
3746 @item <count> C-b | |
3747 <count> pages backward (in older versions @kbd{C-b} only works without count). | |
3748 @item <count> z<cr> | |
3749 @item zH | |
3750 Put line <count> at the top of the window (default the current line). | |
3751 @item <count> z- | |
3752 @item zL | |
3753 Put line <count> at the bottom of the window | |
3754 (default the current line). | |
3755 @item <count> z. | |
3756 @item zM | |
3757 Put line <count> in the center of the window | |
3758 (default the current line). | |
3759 @end table | |
3760 @kindex @kbd{zM} | |
3761 @kindex @kbd{zL} | |
3762 @kindex @kbd{zH} | |
3763 @kindex @kbd{z<cr>} | |
3764 @kindex @kbd{z.} | |
3765 @kindex @kbd{z-} | |
3766 @kindex @kbd{z<cr>} | |
3767 @kindex @kbd{C-b} | |
3768 @kindex @kbd{C-f} | |
3769 @kindex @kbd{C-u} | |
3770 @kindex @kbd{C-d} | |
3771 @kindex @kbd{C-y} | |
3772 @kindex @kbd{C-e} | |
3773 @kindex @kbd{C-l} | |
3774 @kindex @kbd{C-g} | |
3775 | |
3776 | |
3777 @node File and Buffer Handling, Mapping, Display,Commands | |
3778 @section File and Buffer Handling | |
3779 | |
3780 @cindex multiple files | |
3781 | |
3782 In all file handling commands, space should be typed before entering the file | |
3783 name. If you need to type a modifier, such as @kbd{>>} or @kbd{!}, don't | |
3784 put any space between the command and the modifier. | |
3785 | |
3786 @table @kbd | |
3787 @item :q | |
3788 Quit buffer except if modified. | |
3789 @item :q! | |
3790 Quit buffer without checking. In Viper, these two commands | |
3791 are identical. Confirmation is required if exiting modified buffers that | |
3792 visit files. | |
3793 @item :susp | |
3794 @item :stop | |
3795 Suspend Viper | |
3796 @item :[x,y] w | |
3797 Write the file. Viper nakes sure that a final newline is always added to | |
3798 any file where this newline is missing. This is done by setting Emacs | |
3799 variable @code{require-final-newline} to @code{t}. If you don't like this | |
3800 feature, use @code{setq-default} to set @code{require-final-newline} to | |
3801 @code{nil}. This must be done either in @file{.viper} file or in | |
3802 @code{.emacs} after Viper is loaded. | |
3803 @item :[x,y] w <name> | |
3804 Write to the file <name>. | |
3805 @item :[x,y] w>> <name> | |
3806 Append the buffer to the file <name>. There should be no space between | |
3807 @kbd{w} and @kbd{>>}. Type space after the @kbd{>>} and see what happens. | |
3808 @item :w! <name> | |
3809 Overwrite the file <name>. In Viper, @kbd{:w} and @kbd{:w!} are identical. | |
3810 Confirmation is required for writing to an existing file (if this is not | |
3811 the file the buffer is visiting) or to a read-only file. | |
3812 @item :x,y w <name> | |
3813 Write lines x through y to the file <name>. | |
3814 @item :wq | |
3815 Write the file and kill buffer. | |
3816 @item :r <file> [<file> ...] | |
3817 Read file into a buffer, inserting its contents after the current line. | |
3818 @item :xit | |
3819 Same as @kbd{:wq}. | |
3820 @item :W | |
3821 Save unsaved buffers, asking for confirmation. | |
3822 @item :WW | |
3823 Like @kbd{W}, but without asking for confirmation. | |
3824 @item ZZ | |
3825 Save current buffer and kill it. If user level is 1, then save all files | |
3826 and kill Emacs. Killing Emacs is the wrong way to use it, so you should | |
3827 switch to higher user levels as soon as possible. | |
3828 @item :x [<file>] | |
3829 Save and kill buffer. | |
3830 @item :x! [<file>] | |
3831 @kbd{:w![<file>]} and @kbd{:q}. | |
3832 @item :pre | |
3833 Preserve the file -- autosave buffers. | |
3834 @item :rec | |
3835 Recover file from autosave. | |
3836 @item :f | |
3837 Print file name and lines. | |
3838 @item :cd [<dir>] | |
3839 Set the working directory to <dir> (default home directory). | |
3840 @item :pwd | |
3841 Print present working directory. | |
3842 @item :e [+<cmd>] <files> | |
3843 Edit files. If no filename is given, edit the file visited by the current | |
3844 buffer. If buffer was modified or the file changed on disk, ask for | |
3845 confirmation. Unlike Vi, Viper allows @kbd{:e} to take multiple arguments. | |
3846 The first file is edited the same way as in Vi. The rest are visited | |
3847 in the usual Emacs way. | |
3848 @item :e! [+<cmd>] <files> | |
3849 Re-edit file. If no filename, reedit current file. | |
3850 In Viper, unlike Vi, @kbd{e!} is identical to @kbd{:e}. In both cases, the | |
3851 user is asked to confirm if there is a danger of discarding changes to a | |
3852 buffer. | |
3853 @item :q! | |
3854 Quit Vi without writing. | |
3855 @item C-^ | |
3856 Edit the alternate (normally the previous) file. | |
3857 @item :rew | |
3858 Obsolete | |
3859 @item :args | |
3860 List files not shown anywhere with counts for next | |
3861 @item :n [count] [+<cmd>] [<files>] | |
3862 Edit <count> file, or edit files. The count comes from :args. | |
3863 @item :N [count] [+<cmd>] [<files>] | |
3864 Like @kbd{:n}, but the meaning of the variable | |
3865 @var{ex-cycle-other-window} is reversed. | |
3866 @item :b | |
3867 Switch to another buffer. If @var{ex-cycle-other-window} is @code{t}, | |
3868 switch in another window. Buffer completion is supported. | |
3869 @item :B | |
3870 Like @kbd{:b}, but the meaning of @var{ex-cycle-other-window} is reversed. | |
3871 @item :<address>r <name> | |
3872 Read the file <name> into the buffer after the line <address>. | |
3873 @item v, V, C-v | |
3874 Edit a file in current or another window, or in another frame. File name | |
3875 is typed in Minibuffer. File completion and history are supported. | |
3876 @end table | |
3877 @kindex @kbd{v} | |
3878 @kindex @kbd{V} | |
3879 @findex @kbd{:args} | |
3880 @findex @kbd{:rew} | |
3881 @kindex @kbd{C-^} | |
3882 @findex @kbd{:e! [<files>]} | |
3883 @findex @kbd{:e [<files>]} | |
3884 @findex @kbd{:edit [<files>]} | |
3885 @findex @kbd{:edit! [<files>]} | |
3886 @findex @kbd{:q!} | |
3887 @findex @kbd{:q} | |
3888 @findex @kbd{:quit} | |
3889 @findex @kbd{:quit!} | |
3890 @findex @kbd{:f} | |
3891 @findex @kbd{:rec} | |
3892 @findex @kbd{:r} | |
3893 @findex @kbd{:read} | |
3894 @findex @kbd{:pre} | |
3895 @kindex @kbd{ZZ} | |
3896 @findex @kbd{:wq} | |
3897 @findex @kbd{:w <file>} | |
3898 @findex @kbd{:w! <file>} | |
3899 @findex @kbd{:w >> <file>} | |
3900 @findex @kbd{:write <file>} | |
3901 @findex @kbd{:write! <file>} | |
3902 @findex @kbd{:write >> <file>} | |
3903 @findex @kbd{:W} | |
3904 @findex @kbd{:WW} | |
3905 @findex @kbd{:Write} | |
3906 @findex @kbd{:WWrite} | |
3907 @findex @kbd{:WWrite} | |
3908 @findex @kbd{:x} | |
3909 @findex @kbd{:x!} | |
3910 @findex @kbd{:susp} | |
3911 @findex @kbd{:stop} | |
3912 @findex @kbd{:n [<count> | <file>]} | |
3913 @findex @kbd{:cd [<dir>]} | |
3914 @findex @kbd{:pwd} | |
3915 | |
3916 @node Mapping, Shell Commands, File and Buffer Handling, Commands | |
3917 @section Mapping | |
3918 | |
3919 @cindex keybindings | |
3920 @cindex keymapping | |
3921 | |
3922 @table @kbd | |
3923 @item :map <string> | |
3924 Start defining a Vi-style keyboard macro. | |
3925 For instance, typing | |
3926 @kbd{:map www} followed by @kbd{:!wc %} and then typing @kbd{C-x )} | |
3927 will cause @kbd{www} to run wc on | |
3928 current file (Vi replaces @samp{%} with the current file name). | |
3929 @item C-x ) | |
3930 Finish defining a keyboard macro. | |
3931 In Viper, this command completes the process of defining all keyboard | |
3932 macros, whether they are Emacs-style or Vi-style. | |
3933 This is a departure from Vi, needed to allow WYSIWYG mapping of | |
3934 keyboard macros and to permit the use of function keys and arbitrary Emacs | |
3935 functions in the macros. | |
3936 @item :unmap <string> | |
3937 Deprive <string> of its mappings in Vi state. | |
3938 @item :map! <string> | |
3939 Map a macro for Insert state. | |
3940 @item :unmap! <string> | |
3941 Deprive <string> of its mapping in Insert state (see @kbd{:unmap}). | |
3942 @item @@<a-z> | |
3943 In Vi state, | |
3944 execute the contents of register as a command. | |
3945 @item @@@@ | |
3946 In Vi state, | |
3947 repeat last register command. | |
3948 @item @@# | |
3949 In Vi state, | |
3950 begin keyboard macro. End with @@<a-z>. This will | |
3951 put the macro in the proper register. Register will | |
3952 be automatically downcased. | |
3953 @xref{Macros and Registers}, for more info. | |
3954 @item @@!<a-z> | |
3955 In Vi state, | |
3956 yank anonymous macro to register | |
3957 @item * | |
3958 In Vi state, | |
3959 execute anonymous macro (defined by C-x( and C-x )). | |
3960 @item C-x e | |
3961 Like @kbd{*}, but works in all Viper states. | |
3962 @item #g<move> | |
3963 Execute the last keyboard macro for each line in the region. | |
3964 @xref{Macros and Registers}, for more info. | |
3965 @item [<a-z> | |
3966 Show contents of textmarker. | |
3967 @item ]<a-z> | |
3968 Show contents of register. | |
3969 @end table | |
3970 @kindex @kbd{]<a-z>} | |
3971 @kindex @kbd{[<a-z>} | |
3972 @kindex @kbd{#g<move>} | |
3973 @kindex @kbd{*} | |
3974 @kindex @kbd{@@!<a-z>} | |
3975 @kindex @kbd{@@#} | |
3976 @kindex @kbd{@@@@} | |
3977 @kindex @kbd{@@<a-z>} | |
3978 @findex @kbd{:unmap <char>} | |
3979 @findex @kbd{:map <char> <seq>} | |
3980 @findex @kbd{:unmap! <char>} | |
3981 @findex @kbd{:map! <char> <seq>} | |
3982 | |
3983 @node Shell Commands, Options, Mapping, Commands | |
3984 @section Shell Commands | |
3985 | |
3986 @cindex % (Current file) | |
3987 | |
3988 Note that % is used in Ex commands to mean current file. If you want a % | |
3989 in your command, it must be escaped as @samp{\%}. | |
3990 @cindex % (Ex address) | |
3991 However if % is the | |
3992 first character, it stands as the address for the whole file. | |
3993 @cindex # (Previous file) | |
3994 Similarly, @samp{#} expands to the previous file. The previous file is | |
3995 the first file in @kbd{:args} listing. This defaults | |
3996 to the previous file in the VI sense if you have one window.@refill | |
3997 | |
3998 @cindex shell commands | |
3999 | |
4000 @table @kbd | |
4001 @item :sh | |
4002 Execute a subshell in another window | |
4003 @item :[x,y]!<cmd> | |
4004 Execute a shell <cmd> [on lines x through y; | |
4005 % is replace by current file, \% is changed to % | |
4006 @item :[x,y]!! [<args>] | |
4007 Repeat last shell command [and append <args>]. | |
4008 @item :!<cmd> | |
4009 Just execute command and display result in a buffer. | |
4010 @item :!! <args> | |
4011 Repeat last shell command and append <args> | |
4012 @item <count> !<move><cmd> | |
4013 The shell executes <cmd>, with standard | |
4014 input the lines described by <count><move>, | |
4015 next the standard output replaces those lines | |
4016 (think of @samp{cb}, @samp{sort}, @samp{nroff}, etc.). | |
4017 @item <count> !!<cmd> | |
4018 Give <count> lines as standard input to the | |
4019 shell <cmd>, next let the standard output | |
4020 replace those lines. | |
4021 @item :[x,y] w !<cmd> | |
4022 Let lines x to y be standard input for <cmd> | |
4023 (notice the <sp> between @kbd{w} and @kbd{!}). | |
4024 @item :<address>r !<cmd> | |
4025 Put the output of <cmd> after the line <address> (default current). | |
4026 @item :<address>r <name> | |
4027 Read the file <name> into the buffer after the line <address> (default | |
4028 current). | |
4029 @end table | |
4030 @findex @kbd{:<address>r <name>} | |
4031 @findex @kbd{:<address>r !<cmd>} | |
4032 @findex @kbd{!<cmd>} | |
4033 @findex @kbd{!!<cmd>} | |
4034 @findex @kbd{!<move><cmd>} | |
4035 @findex @kbd{:w !<cmd>} | |
4036 @findex @kbd{:x,y w !<cmd>} | |
4037 @findex @kbd{:!! <args>} | |
4038 @findex @kbd{:!<cmd>} | |
4039 @findex @kbd{:sh} | |
4040 | |
4041 @node Options,Emacs Related Commands,Shell Commands,Commands | |
4042 @section Options | |
4043 | |
4044 @cindex Vi options | |
4045 | |
4046 @table @kbd | |
4047 @item ai | |
4048 @cindex autoindent | |
4049 autoindent -- In append mode after a <cr> the | |
4050 cursor will move directly below the first | |
4051 CHAR on the previous line. | |
4052 @item ic | |
4053 @cindex case and searching | |
4054 ignorecase -- No distinction between upper and lower cases when searching. | |
4055 @item magic | |
4056 @cindex literal searching | |
4057 Regular expressions used in searches; nomagic means no regexps. | |
4058 @item ro | |
4059 @cindex readonly files | |
4060 readonly -- The file is not to be changed. | |
4061 If the user attempts to write to this file, confirmation will be requested. | |
4062 @item sh=<string> | |
4063 @cindex shell | |
4064 shell -- The program to be used for shell escapes | |
4065 (default @samp{$SHELL} (default @file{/bin/sh})). | |
4066 @item sw=<count> | |
4067 @cindex layout | |
4068 @cindex shifting text | |
4069 shiftwidth -- Gives the shiftwidth (default 8 positions). | |
4070 @item sm | |
4071 @cindex paren matching | |
4072 @cindex matching parens | |
4073 showmatch -- Whenever you append a @kbd{)}, Vi shows | |
4074 its match if it's on the same page; also with | |
4075 @kbd{@{} and @kbd{@}}. If there's no match, Vi will beep. | |
4076 @item ts=<count> | |
4077 @cindex changing tab width | |
4078 @cindex tabbing | |
4079 tabstop -- The length of a <ht>; warning: this is | |
4080 only IN the editor, outside of it <ht>s have | |
4081 their normal length (default 8 positions). | |
4082 @item wm=<count> | |
4083 @cindex auto fill | |
4084 @cindex word wrap | |
4085 wrapmargin -- In append mode Vi automatically | |
4086 puts a <lf> whenever there is a <sp> or <ht> | |
4087 within <wm> columns from the right margin. | |
4088 @item ws | |
4089 @cindex searching | |
4090 wrapscan -- When searching, the end is | |
4091 considered @samp{stuck} to the begin of the file. | |
4092 @item :set <option> | |
4093 Turn <option> on. | |
4094 @item :set no<option> | |
4095 Turn <option> off. | |
4096 @item :set <option>=<value> | |
4097 Set <option> to <value>. | |
4098 @end table | |
4099 @findex @kbd{:set <option>=<value>} | |
4100 @findex @kbd{:set no<option>} | |
4101 @findex @kbd{:set <option>} | |
4102 @findex @kbd{:set ws} | |
4103 @findex @kbd{:set wrapscan} | |
4104 @findex @kbd{:set wm=<count>} | |
4105 @findex @kbd{:set wrapmargin=<count>} | |
4106 @findex @kbd{:set ts=<count>} | |
4107 @findex @kbd{:set tabstop=<count>} | |
4108 @findex @kbd{:set tab-stop-local=<count>} | |
4109 @findex @kbd{:set sm} | |
4110 @findex @kbd{:set showmatch} | |
4111 @findex @kbd{:set sw=<count>} | |
4112 @findex @kbd{:set shiftwidth=<count>} | |
4113 @findex @kbd{:set sh=<string>} | |
4114 @findex @kbd{:set shell=<string>} | |
4115 @findex @kbd{:set ro} | |
4116 @findex @kbd{:set readonly} | |
4117 @findex @kbd{:set magic} | |
4118 @findex @kbd{:set ic} | |
4119 @findex @kbd{:set ignorecase} | |
4120 @findex @kbd{:set ai} | |
4121 @findex @kbd{:set autoindent} | |
4122 | |
4123 @node Emacs Related Commands,,Options,Commands | |
4124 @section Emacs Related Commands | |
4125 | |
4126 @table @kbd | |
4127 @item _ | |
4128 Begin Meta command in Vi state. Most often used as _x (M-x). | |
4129 @item C-z | |
4130 Begin Meta command in Insert state. | |
4131 @item C-z | |
4132 Switch between Emacs and Vi states. | |
4133 @item C-x0 | |
4134 Close Window | |
4135 @item C-x1 | |
4136 Close Other Windows | |
4137 @item C-x2 | |
4138 Split Window | |
4139 @item C-xo | |
4140 Move among windows | |
4141 @item C-xC-f | |
4142 Emacs find-file, useful in Insert state | |
4143 @item C-y | |
4144 Put back the last killed text. Similar to Vi's @kbd{p}, but also works in | |
4145 Insert and Replace state. This command doesn't work in Vi command state, | |
4146 since this binding is taken for something else. | |
4147 @item M-y | |
4148 Undoes the last @kbd{C-y} and puts another kill from the kill ring. | |
4149 Using this command, you can try may different kills until you find the one | |
4150 you need. | |
4151 @end table | |
4152 @kindex @kbd{M-y} | |
4153 @kindex @kbd{C-y} | |
4154 @kindex @kbd{C-xC-f} | |
4155 @kindex @kbd{C-xo} | |
4156 @kindex @kbd{C-x2} | |
4157 @kindex @kbd{C-x1} | |
4158 @kindex @kbd{C-x0} | |
4159 @kindex @kbd{C-z} | |
4160 @kindex @kbd{C-z} | |
4161 @kindex @kbd{_} | |
4162 | |
4163 @node Mouse-bound Commands,,,Commands | |
4164 @section Mouse-bound Commands | |
4165 | |
4166 The following two mouse actions are normally bound to to special search and | |
4167 insert commands in of Viper: | |
4168 | |
4169 @table @kbd | |
4170 @item S-mouse-1 (Emacs) | |
4171 @item meta button1up (XEmacs) | |
4172 Holding Shift (or Meta, if XEmacs) and clicking mouse button 1 will | |
4173 initiate search for | |
4174 a region under the mouse pointer. | |
4175 This command can take a prefix argument. Note: Viper sets this | |
4176 binding only if this mouse action is not | |
4177 already bound to something else. | |
4178 @xref{Viper Specials}, for more information.@refill | |
4179 | |
4180 @item S-mouse-2 (Emacs) | |
4181 @item meta button2up (XEmacs) | |
4182 Holding Shift (or Meta, if XEmacs) and clicking button 2 of the mouse will | |
4183 insert a region surrounding the mouse pointer. | |
4184 This command can also take a prefix argument. | |
4185 Note: Viper sets this binding only if this mouse action is not | |
4186 already bound to something else. | |
4187 @xref{Viper Specials}, for more details.@refill | |
4188 @end table | |
4189 @kindex @kbd{S-mouse-1} | |
4190 @kindex @kbd{S-mouse-2} | |
4191 @kindex @kbd{meta button1up} | |
4192 @kindex @kbd{meta button2up} | |
2929 | 4193 |
2930 @node Acknowledgments,,,Top | 4194 @node Acknowledgments,,,Top |
2931 @comment node-name, next, previous, up | 4195 @comment node-name, next, previous, up |
2932 @unnumbered Acknowledgments | 4196 @unnumbered Acknowledgments |
2933 | 4197 |