comparison doc/misc/viper.texi @ 104278:25648648783d

2009-08-15 Michael Kifer <kifer@cs.stonybrook.edu> * ediff.texi (ediff-current-file): added information about this new function. * viper.text: Added information about C-s in viper's search command.
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sat, 15 Aug 2009 06:00:38 +0000
parents 9bcea07061a8
children 1d1d5d9bd884
comparison
equal deleted inserted replaced
104277:affb617d6101 104278:25648648783d
259 a buffer to a file, then the buffer will become not modified. Also if 259 a buffer to a file, then the buffer will become not modified. Also if
260 you see @samp{%%} at the beginning of the mode line, it means that the file 260 you see @samp{%%} at the beginning of the mode line, it means that the file
261 associated with the buffer is write protected. The mode line will also 261 associated with the buffer is write protected. The mode line will also
262 show the buffer name and current major and minor modes (see below). 262 show the buffer name and current major and minor modes (see below).
263 A special buffer called @dfn{Minibuffer} is displayed as the last line 263 A special buffer called @dfn{Minibuffer} is displayed as the last line
264 in a Minibuffer window. The Minibuffer window is used for command input 264 in a minibuffer window. The minibuffer window is used for command input
265 output. Viper uses Minibuffer window for @kbd{/} and @kbd{:} 265 output. Viper uses minibuffer window for @kbd{/} and @kbd{:}
266 commands.@refill 266 commands.@refill
267 267
268 @cindex mode 268 @cindex mode
269 @cindex keymap 269 @cindex keymap
270 @cindex local keymap 270 @cindex local keymap
651 last history element is the default that can be invoked simply by typing 651 last history element is the default that can be invoked simply by typing
652 @kbd{: @key{RET}}. If @kbd{:w!@: foo} were placed on the list, it would be all to 652 @kbd{: @key{RET}}. If @kbd{:w!@: foo} were placed on the list, it would be all to
653 easy to override valuable data in another file. Reconstructing the full 653 easy to override valuable data in another file. Reconstructing the full
654 command, @kbd{:w!@: foo}, from the history is still not that hard, since Viper 654 command, @kbd{:w!@: foo}, from the history is still not that hard, since Viper
655 has a separate history for file names. By typing @kbd{: M-p}, you will get 655 has a separate history for file names. By typing @kbd{: M-p}, you will get
656 @kbd{:w!} in the Minibuffer. Then, repeated @kbd{M-p} will get you through 656 @kbd{:w!} in the minibuffer. Then, repeated @kbd{M-p} will get you through
657 the file history, inserting one file name after another. 657 the file history, inserting one file name after another.
658 658
659 In contrast to @kbd{:w!@: foo}, if the command were @kbd{:r foo}, the entire 659 In contrast to @kbd{:w!@: foo}, if the command were @kbd{:r foo}, the entire
660 command will appear in the history list. This is because having @kbd{:r} 660 command will appear in the history list. This is because having @kbd{:r}
661 alone as a default is meaningless, since this command requires a file 661 alone as a default is meaningless, since this command requires a file
662 argument. 662 argument.
663 @refill 663 @refill
664 @end table 664 @end table
665 @noindent 665 @noindent
666 As Vi, Viper's destructive commands can be re-executed by typing `@kbd{.}'. 666 As in Vi, Viper's destructive commands can be re-executed by typing `@kbd{.}'.
667 However, in addition, Viper keeps track of the history of such commands. This 667 However, in addition, Viper keeps track of the history of such commands. This
668 history can be perused by typing @kbd{C-c M-p} and @kbd{C-c M-n}. 668 history can be perused by typing @kbd{C-c M-p} and @kbd{C-c M-n}.
669 Having found the appropriate command, it can be then executed by typing 669 Having found the appropriate command, it can be then executed by typing
670 `@kbd{.}'. 670 `@kbd{.}'.
671 @xref{Improvements over Vi}, for more information. 671 @xref{Improvements over Vi}, for more information.
765 @node The Minibuffer,Multiple Files in Viper, States in Viper, Overview 765 @node The Minibuffer,Multiple Files in Viper, States in Viper, Overview
766 @section The Minibuffer 766 @section The Minibuffer
767 767
768 @cindex Minibuffer 768 @cindex Minibuffer
769 769
770 The Minibuffer is where commands are entered in. Editing can be done 770 The minibuffer is where commands are entered in. Editing can be done
771 by commands from Insert state, namely: 771 by commands from Insert state, namely:
772 772
773 @table @kbd 773 @table @kbd
774 @item C-h 774 @item C-h
775 Backspace 775 Backspace
786 explanation. 786 explanation.
787 @item M-p and M-n 787 @item M-p and M-n
788 These keys are bound to functions that peruse minibuffer history. The 788 These keys are bound to functions that peruse minibuffer history. The
789 precise history to be perused depends on the context. It may be the history 789 precise history to be perused depends on the context. It may be the history
790 of search strings, Ex commands, file names, etc. 790 of search strings, Ex commands, file names, etc.
791 @item C-s
792 If the minibuffer is entered via the Viper search commands @kbd{/} or
793 @kbd{?}, then this key inserts the last search string used by the
794 Emacs incremental search command
795 (which is bound to @kbd{C-s} everywhere except in this case).
791 @end table 796 @end table
792 797
793 Most of the Emacs keys are functional in the Minibuffer. While in the 798 Most of the Emacs keys are functional in the minibuffer. While in the
794 Minibuffer, Viper tries to make editing resemble Vi's behavior when the 799 minibuffer, Viper tries to make editing resemble Vi's behavior when the
795 latter is waiting for the user to type an Ex command. In particular, you 800 latter is waiting for the user to type an Ex command. In particular, you
796 can use the regular Vi commands to edit the Minibuffer. You can switch 801 can use the regular Vi commands to edit the minibuffer. You can switch
797 between the Vi state and Insert state at will, and even use the replace mode. 802 between the Vi state and Insert state at will, and even use the replace mode.
798 Initially, the Minibuffer comes up in Insert state. 803 Initially, the minibuffer comes up in Insert state.
799 804
800 Some users prefer plain Emacs bindings in the Minibuffer. To this end, set 805 Some users prefer plain Emacs bindings in the minibuffer. To this end, set
801 @code{viper-vi-style-in-minibuffer} to @code{nil} in @file{.viper}. 806 @code{viper-vi-style-in-minibuffer} to @code{nil} in @file{.viper}.
802 @xref{Customization}, to learn how to do this. 807 @xref{Customization}, to learn how to do this.
803 808
804 When the Minibuffer changes Viper states, you will notice that the appearance 809 When the minibuffer changes Viper states, you will notice that the appearance
805 of the text there changes as well. This is useful because the Minibuffer 810 of the text there changes as well. This is useful because the minibuffer
806 has no mode line to tell which Vi state it is in. 811 has no mode line to tell which Vi state it is in.
807 The appearance of the text in the Minibuffer can be changed. 812 The appearance of the text in the minibuffer can be changed.
808 @xref{Viper Specials}, for more details. 813 @xref{Viper Specials}, for more details.
809 814
810 @node Multiple Files in Viper,Unimplemented Features,The Minibuffer,Overview 815 @node Multiple Files in Viper,Unimplemented Features,The Minibuffer,Overview
811 @section Multiple Files in Viper 816 @section Multiple Files in Viper
812 817
857 @cindex absolute file names 862 @cindex absolute file names
858 The current directory name for a file is automatically prepended to the 863 The current directory name for a file is automatically prepended to the
859 file name in any 864 file name in any
860 @kbd{:e}, @kbd{:r}, @kbd{:w}, etc., command (in Emacs, each buffer has a 865 @kbd{:e}, @kbd{:r}, @kbd{:w}, etc., command (in Emacs, each buffer has a
861 current directory). 866 current directory).
862 This directory is inserted in the Minibuffer once you type space after 867 This directory is inserted in the minibuffer once you type space after
863 @kbd{:e, r}, etc. Viper also supports completion of file names and Ex 868 @kbd{:e, r}, etc. Viper also supports completion of file names and Ex
864 commands (@key{TAB}), and it keeps track of 869 commands (@key{TAB}), and it keeps track of
865 command and file history (@kbd{M-p}, @kbd{M-n}). 870 command and file history (@kbd{M-p}, @kbd{M-n}).
866 Absolute filenames are required less 871 Absolute filenames are required less
867 often in Viper. 872 often in Viper.
1042 text inserted in earlier commands that use Insert or Replace state, and for 1047 text inserted in earlier commands that use Insert or Replace state, and for
1043 destructive commands in Vi state. These are 1048 destructive commands in Vi state. These are
1044 useful for fixing those small typos that screw up searches and @kbd{:s}, 1049 useful for fixing those small typos that screw up searches and @kbd{:s},
1045 and for eliminating routine associated with repeated typing of file names 1050 and for eliminating routine associated with repeated typing of file names
1046 or pieces of text that need to be inserted frequently. 1051 or pieces of text that need to be inserted frequently.
1047 At the @kbd{:} or @kbd{/} prompts in the Minibuffer, you can do the following: 1052 At the @kbd{:} or @kbd{/} prompts in the minibuffer, you can do the following:
1048 1053
1049 @table @kbd 1054 @table @kbd
1050 @item M-p and M-n 1055 @item M-p and M-n
1051 To move to previous and next history items. This causes the history 1056 To move to previous and next history items. This causes the history
1052 items to appear on the command line, where you can edit them, or 1057 items to appear on the command line, where you can edit them, or
1168 Search,emacs,The GNU Emacs Manual} @refill 1173 Search,emacs,The GNU Emacs Manual} @refill
1169 1174
1170 @cindex query replace 1175 @cindex query replace
1171 1176
1172 Viper also provides a query replace function that prompts through the 1177 Viper also provides a query replace function that prompts through the
1173 Minibuffer. It is invoked by the @kbd{Q} key in Vi state. 1178 minibuffer. It is invoked by the @kbd{Q} key in Vi state.
1174 1179
1175 @cindex mouse search 1180 @cindex mouse search
1176 1181
1177 On a window display, Viper supports mouse search, i.e., you can search for a 1182 On a window display, Viper supports mouse search, i.e., you can search for a
1178 word by clicking on it. @xref{Viper Specials}, for details. 1183 word by clicking on it. @xref{Viper Specials}, for details.
1330 @itemx C-v 1335 @itemx C-v
1331 @kindex @kbd{v} 1336 @kindex @kbd{v}
1332 @kindex @kbd{V} 1337 @kindex @kbd{V}
1333 @kindex @kbd{C-v} 1338 @kindex @kbd{C-v}
1334 These keys are used to visit files. @kbd{v} will switch to a buffer 1339 These keys are used to visit files. @kbd{v} will switch to a buffer
1335 visiting file whose name can be entered in the Minibuffer. @kbd{V} is 1340 visiting file whose name can be entered in the minibuffer. @kbd{V} is
1336 similar, but will use a window different from the current window. 1341 similar, but will use a window different from the current window.
1337 @kbd{C-v} is like @kbd{V}, except that a new frame (X window) will be used 1342 @kbd{C-v} is like @kbd{V}, except that a new frame (X window) will be used
1338 instead of a new Emacs window. 1343 instead of a new Emacs window.
1339 @item # 1344 @item #
1340 @kindex @kbd{#} 1345 @kindex @kbd{#}
1430 @cindex case-insensitive search 1435 @cindex case-insensitive search
1431 1436
1432 @item M-p and M-n 1437 @item M-p and M-n
1433 @kindex @kbd{M-p} 1438 @kindex @kbd{M-p}
1434 @kindex @kbd{M-n} 1439 @kindex @kbd{M-n}
1435 In the Minibuffer, these commands navigate through the minibuffer 1440 In the minibuffer, these commands navigate through the minibuffer
1436 histories, such as the history of search strings, Ex commands, etc. 1441 histories, such as the history of search strings, Ex commands, etc.
1442
1443 @item C-s
1444 @kindex @kbd{C-s}
1445 If the minibuffer is entered via a Viper search commands @kbd{/} or @kbd{?},
1446 then typing this key inserts the last search string used by the
1447 Emacs incremental search command (that is bound to @kbd{C-s} everywhere
1448 except in this case).
1437 1449
1438 @item C-c M-p and C-c M-n 1450 @item C-c M-p and C-c M-n
1439 @kindex @kbd{C-c M-p} 1451 @kindex @kbd{C-c M-p}
1440 @kindex @kbd{C-c M-n} 1452 @kindex @kbd{C-c M-n}
1441 @cindex Insertion history 1453 @cindex Insertion history
1714 @item viper-want-ctl-h-help nil 1726 @item viper-want-ctl-h-help nil
1715 If not @code{nil}, @kbd{C-h} is bound to @code{help-command}; 1727 If not @code{nil}, @kbd{C-h} is bound to @code{help-command};
1716 otherwise, @kbd{C-h} is bound as usual in Vi. 1728 otherwise, @kbd{C-h} is bound as usual in Vi.
1717 @item viper-vi-style-in-minibuffer t 1729 @item viper-vi-style-in-minibuffer t
1718 If not @code{nil}, Viper provides a high degree of compatibility with Vi 1730 If not @code{nil}, Viper provides a high degree of compatibility with Vi
1719 insert mode when you type text in the Minibuffer; if @code{nil}, typing in 1731 insert mode when you type text in the minibuffer; if @code{nil}, typing in
1720 the Minibuffer feels like plain Emacs. 1732 the minibuffer feels like plain Emacs.
1721 @item viper-no-multiple-ESC t 1733 @item viper-no-multiple-ESC t
1722 If you set this to @code{nil}, you can use @key{ESC} as Meta in Vi state. 1734 If you set this to @code{nil}, you can use @key{ESC} as Meta in Vi state.
1723 Normally, this is not necessary, since graphical displays have separate 1735 Normally, this is not necessary, since graphical displays have separate
1724 Meta keys (usually on each side of the space bar). On a dumb terminal, Viper 1736 Meta keys (usually on each side of the space bar). On a dumb terminal, Viper
1725 sets this variable to @code{twice}, which is almost like @code{nil}, except 1737 sets this variable to @code{twice}, which is almost like @code{nil}, except
2453 direction, you can either bind an unused key to 2465 direction, you can either bind an unused key to
2454 @code{viper-insert-next-from-insertion-ring} or hit any digit (1 to 9) then 2466 @code{viper-insert-next-from-insertion-ring} or hit any digit (1 to 9) then
2455 @kbd{f31}. 2467 @kbd{f31}.
2456 2468
2457 One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since 2469 One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since
2458 this will interfere with the Minibuffer histories and, possibly, other 2470 this will interfere with the minibuffer histories and, possibly, other
2459 major modes. 2471 major modes.
2460 2472
2461 @item viper-command-ring-size 14 2473 @item viper-command-ring-size 14
2462 @vindex @code{viper-command-ring-size} 2474 @vindex @code{viper-command-ring-size}
2463 @cindex Destructive command ring 2475 @cindex Destructive command ring
2483 commands. To search in the opposite 2495 commands. To search in the opposite
2484 direction, you can either bind an unused key to 2496 direction, you can either bind an unused key to
2485 @code{viper-next-destructive-command} or hit any digit (1 to 9) then @kbd{f31}. 2497 @code{viper-next-destructive-command} or hit any digit (1 to 9) then @kbd{f31}.
2486 2498
2487 One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since 2499 One should not bind the above functions to @kbd{M-p} or @kbd{M-n}, since
2488 this will interfere with the Minibuffer histories and, possibly, other 2500 this will interfere with the minibuffer histories and, possibly, other
2489 major modes. 2501 major modes.
2490 2502
2491 @item viper-minibuffer-vi-face 'viper-minibuffer-vi-face 2503 @item viper-minibuffer-vi-face 'viper-minibuffer-vi-face
2492 @item viper-minibuffer-insert-face 'viper-minibuffer-insert-face 2504 @item viper-minibuffer-insert-face 'viper-minibuffer-insert-face
2493 @item viper-minibuffer-emacs-face 'viper-minibuffer-emacs-face 2505 @item viper-minibuffer-emacs-face 'viper-minibuffer-emacs-face
2499 Viper is located in this widget under the @emph{Emulations} customization 2511 Viper is located in this widget under the @emph{Emulations} customization
2500 subgroup of the @emph{Editing} group. All Viper faces are grouped together 2512 subgroup of the @emph{Editing} group. All Viper faces are grouped together
2501 in Viper's @emph{Highlighting} customization subgroup. 2513 in Viper's @emph{Highlighting} customization subgroup.
2502 2514
2503 Note that only the text you type in is affected by the above faces. 2515 Note that only the text you type in is affected by the above faces.
2504 Prompts and Minibuffer messages are not affected. 2516 Prompts and minibuffer messages are not affected.
2505 2517
2506 Purists who do not like adornments in the minibuffer can always zap them by 2518 Purists who do not like adornments in the minibuffer can always zap them by
2507 putting 2519 putting
2508 @example 2520 @example
2509 (copy-face 'default 'viper-minibuffer-vi-face) 2521 (copy-face 'default 'viper-minibuffer-vi-face)
2958 This is because it is all too easy to create an infinite loop in this way. 2970 This is because it is all too easy to create an infinite loop in this way.
2959 Since Viper macros are much more powerful than Vi's it is impossible to 2971 Since Viper macros are much more powerful than Vi's it is impossible to
2960 detect such loops. In practice, this is not really a limitation but, 2972 detect such loops. In practice, this is not really a limitation but,
2961 rather, a feature. 2973 rather, a feature.
2962 2974
2963 We should also note that Vi macros are disabled in the Minibuffer, which 2975 We should also note that Vi macros are disabled in the minibuffer, which
2964 helps keep some potential troubles away. 2976 helps keep some potential troubles away.
2965 2977
2966 The rate at which the user must type keys in order for them to be 2978 The rate at which the user must type keys in order for them to be
2967 recognized as a timeout macro is controlled by the variable 2979 recognized as a timeout macro is controlled by the variable
2968 @code{viper-fast-keyseq-timeout}, which defaults to 200 milliseconds. 2980 @code{viper-fast-keyseq-timeout}, which defaults to 200 milliseconds.
3532 In Vi state, 3544 In Vi state,
3533 these commands help peruse the history of Vi's destructive commands. 3545 these commands help peruse the history of Vi's destructive commands.
3534 Successive typing of @kbd{C-c M-p} causes Viper to search the history in 3546 Successive typing of @kbd{C-c M-p} causes Viper to search the history in
3535 the direction 3547 the direction
3536 of older commands, while hitting @kbd{C-c M-n} does so in reverse 3548 of older commands, while hitting @kbd{C-c M-n} does so in reverse
3537 order. Each command in the history is displayed in the Minibuffer. The 3549 order. Each command in the history is displayed in the minibuffer. The
3538 displayed command can 3550 displayed command can
3539 then be executed by typing `@kbd{.}'. 3551 then be executed by typing `@kbd{.}'.
3540 3552
3541 Since typing the above sequences of keys may be tedious, the 3553 Since typing the above sequences of keys may be tedious, the
3542 functions doing the perusing can be bound to unused keyboard keys in the 3554 functions doing the perusing can be bound to unused keyboard keys in the
3562 @node Editing in Insert State, Deleting Text, Appending Text,Text Handling 3574 @node Editing in Insert State, Deleting Text, Appending Text,Text Handling
3563 @subsection Editing in Insert State 3575 @subsection Editing in Insert State
3564 3576
3565 Minibuffer can be edited similarly to Insert state, and you can switch 3577 Minibuffer can be edited similarly to Insert state, and you can switch
3566 between Insert/Replace/Vi states at will. 3578 between Insert/Replace/Vi states at will.
3567 Some users prefer plain Emacs feel in the Minibuffer. To this end, set 3579 Some users prefer plain Emacs feel in the minibuffer. To this end, set
3568 @var{viper-vi-style-in-minibuffer} to @code{nil}. 3580 @var{viper-vi-style-in-minibuffer} to @code{nil}.
3569 3581
3570 @cindex Insert state 3582 @cindex Insert state
3571 3583
3572 @table @kbd 3584 @table @kbd
3751 To the <count>th occurrence of <string>. 3763 To the <count>th occurrence of <string>.
3752 3764
3753 Viper does not parse search patterns and does not expand special symbols 3765 Viper does not parse search patterns and does not expand special symbols
3754 found there (e.g., @samp{~} is not expanded to the result of the previous 3766 found there (e.g., @samp{~} is not expanded to the result of the previous
3755 substitution). 3767 substitution).
3768
3769 After typing @kbd{/} or @kbd{?} all the usual Emacs minibuffer commands, such as
3770 @kbd{M-p} and @kbd{M-n} are available. In addition, typing @kbd{C-s} will
3771 insert the last search string used by the Emacs incremental search command
3772 (which is bound to @kbd{C-s} everywhere except in this case).
3756 3773
3757 @item <count> ?<string> 3774 @item <count> ?<string>
3758 To the <count>th previous occurrence of <string>. 3775 To the <count>th previous occurrence of <string>.
3759 @item <count> g<move> 3776 @item <count> g<move>
3760 Search for the text described by move. (off by default) 3777 Search for the text described by move. (off by default)
4055 Like @kbd{:b}, but the meaning of @var{ex-cycle-other-window} is reversed. 4072 Like @kbd{:b}, but the meaning of @var{ex-cycle-other-window} is reversed.
4056 @item :<address>r <name> 4073 @item :<address>r <name>
4057 Read the file <name> into the buffer after the line <address>. 4074 Read the file <name> into the buffer after the line <address>.
4058 @item v, V, C-v 4075 @item v, V, C-v
4059 Edit a file in current or another window, or in another frame. File name 4076 Edit a file in current or another window, or in another frame. File name
4060 is typed in Minibuffer. File completion and history are supported. 4077 is typed in minibuffer. File completion and history are supported.
4061 @end table 4078 @end table
4062 @kindex @kbd{v} 4079 @kindex @kbd{v}
4063 @kindex @kbd{V} 4080 @kindex @kbd{V}
4064 @findex @kbd{:args} 4081 @findex @kbd{:args}
4065 @findex @kbd{:rew} 4082 @findex @kbd{:rew}