home *** CD-ROM | disk | FTP | other *** search
/ Dream 49 / Amiga_Dream_49.iso / beos / emacs / emacs-19.34-bin / emacs-19 / info / viper-3 < prev    next >
Encoding:
GNU Info File  |  1997-09-17  |  49.2 KB  |  1,309 lines

  1. This is Info file ../info/viper, produced by Makeinfo-1.63 from the
  2. input file viper.texi.
  3.  
  4. Distribution
  5. ************
  6.  
  7. Copyright (C) 1995, 1996 Free Software Foundation, Inc.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided that
  15. the entire resulting derived work is distributed under the terms of a
  16. permission notice identical to this one.
  17.  
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the same conditions as for modified
  20. versions.
  21.  
  22. 
  23. File: viper,  Node: Viper Specials,  Next: Vi Macros,  Prev: Packages that Change Keymaps,  Up: Customization
  24.  
  25. Viper Specials
  26. ==============
  27.  
  28.    Viper extends Vi with a number of useful features. This includes
  29. various search functions, histories of search strings, Ex commands,
  30. insertions, and Vi's destructive commands. In addition, Viper supports
  31. file name completion and history, completion of Ex commands and
  32. variables, and many other features. Some of these features are
  33. explained in detail elsewhere in this document. Other features are
  34. explained here.
  35.  
  36. `(vip-buffer-search-enable)'
  37. `vip-buffer-search-char nil'
  38.      Enable buffer search. Explicit call to `vip-buffer-search-enable'
  39.      sets `vip-buffer-search-char' to `g'. Alternatively, the user can
  40.      set `vip-buffer-search-char' in `.vip' to a key sequence to be
  41.      used for buffer search. There is no need to call
  42.      `vip-buffer-search-enable' in that case.
  43.  
  44. `vip-toggle-search-style'
  45.      This function, bound to `C-c /', lets one toggle case-sensitive and
  46.      case-insensitive search, and also switch between plain vanilla
  47.      search and search via regular expressions. Without the prefix
  48.      argument, the user is asked which mode to toggle. With prefix
  49.      argument 1, this toggles case-sensitivity. With prefix argument 2,
  50.      regular expression/vanilla search will be toggled.
  51.  
  52.      However, we found that the most convenient way to toggle these
  53.      options is to bind a Vi macro to bind `//' to toggles case
  54.      sensitivity and to `///' to toggles vanilla search. Thus, quickly
  55.      hitting `/' twice will switch Viper from case sensitive search to
  56.      case-insensitive. Repeating this once again will restore the
  57.      original state. Likewise, quickly hitting `/' three times will
  58.      switch you from vanilla-style search to search via regular
  59.      expressions.  If you hit something other than `/' after the first
  60.      `/' or if the second `/' doesn't follow quickly enough, then Viper
  61.      will issue the usual prompt `/' and will wait for input, as usual
  62.      in Vi.  If you don't like this behavior, you can "unrecord" these
  63.      macros in your `~/.vip' file. For instance, if u don't like the
  64.      above feature, put this in `~/.vip':
  65.           (vip-unrecord-kbd-macro "//" 'vi-state)
  66.           (vip-unrecord-kbd-macro "///" 'vi-state)
  67.  
  68.      *Note Vi Macros::, for more information on Vi macros.
  69.  
  70. `vip-heading-start'
  71. `vip-heading-end'
  72.      Regular Expressions for `[[' and `]]'. Note that Emacs defines
  73.      Regexps for paragraphs and sentences. *Note Paragraphs and
  74.      Sentences: (emacs)Paragraphs, for details.
  75.  
  76. `M-x vip-set-expert-level'
  77.      Change your user level interactively.
  78.  
  79. `vip-smart-suffix-list  '("" "tex" "c" "cc" "el" "p")'
  80.      Viper supports Emacs-style file completion when it prompts the
  81.      user for a file name. However, in many cases, the same directory
  82.      may contain files with identical prefix but different suffixes,
  83.      e.g., prog.c, prog.o, paper.tex, paper.dvi. In such cases,
  84.      completion will stop at the `.'.  If the above variable is a list
  85.      of strings representing suffixes, Viper will try these suffixes in
  86.      the order listed and will check if the corresponding file exists.
  87.  
  88.      For instance, if completion stopped at `paper.' and the user typed
  89.      RET, then Viper will check if the files `paper.', `paper.tex',
  90.      `paper.c', etc., exist.  It will take the first such file. If no
  91.      file exists, Viper will give a chance to complete the file name by
  92.      typing the appropriate suffix. If `paper.' was the intended file
  93.      name, hitting return will accept it.
  94.  
  95.      To turn this feature off, set the above variable to `nil'.
  96.  
  97. `vip-insertion-ring-size  14'
  98.      Viper remembers what was previously inserted in Insert and Replace
  99.      states.  Several such recent insertions are kept in a special ring
  100.      of strings of size `vip-insertion-ring-size'.  If you enter Insert
  101.      or Replace state you can reinsert strings from this ring by typing
  102.      `C-c M-p' or `C-c M-n'. The former will search the ring in the
  103.      direction of older insertions, and the latter will search in the
  104.      direction of newer insertions. Hitting `C-c M-p' or `C-c M-n' in
  105.      succession will undo the previous insertion from the ring and
  106.      insert the next item on the ring. If a larger ring size is needed,
  107.      change the value of the above variable in the `~/.vip' file.
  108.  
  109.      Since typing these sequences of keys may be tedious, it is
  110.      suggested that the user should bind a function key, such as `f31',
  111.      as follows:
  112.           (define-key vip-insert-global-user-map [f31]
  113.                       'vip-insert-prev-from-insertion-ring)
  114.      This binds `f31' (which is usually `R11' on a Sun workstation) to
  115.      the function that inserts the previous string in the insertion
  116.      history.  To rotate the history in the opposite direction, you can
  117.      either bind an unused key to `vip-insert-next-from-insertion-ring'
  118.      or hit any digit (1 to 9) then `f31'.
  119.  
  120.      One should not bind the above functions to `M-p' or `M-n', since
  121.      this will interfere with the Minibuffer histories and, possibly,
  122.      other major modes.
  123.  
  124. `vip-command-ring-size  14'
  125.      Viper keeps track of the recent history of destructive commands,
  126.      such as `dw', `i', etc.  In Vi state, the most recent command can
  127.      be re-executed by hitting ``.'', as in Vi.  However, repeated
  128.      typing `C-c M-p' will cause Viper to show the previous destructive
  129.      commands in the minibuffer. Subsequent hitting ``.'' will execute
  130.      the command that was displayed last.  The key `C-c M-n' will cycle
  131.      through the command history in the opposite direction.  Since
  132.      typing `C-c M-p' may be tedious, it is more convenient to bind an
  133.      appropriate function to an unused function key on the keyboard and
  134.      use that key. For instance, the following
  135.           (define-key vip-vi-global-user-map [f31]
  136.                       'vip-prev-destructive-command)
  137.      binds the key `f31' (which is usually `R11' on a Sun workstation)
  138.      to the function that searches the command history in the direction
  139.      of older commands. To search in the opposite direction, you can
  140.      either bind an unused key to `vip-next-destructive-command' or hit
  141.      any digit (1 to 9) then `f31'.
  142.  
  143.      One should not bind the above functions to `M-p' or `M-n', since
  144.      this will interfere with the Minibuffer histories and, possibly,
  145.      other major modes.
  146.  
  147. `vip-minibuffer-vi-face  'vip-minibuffer-vi-face'
  148. `vip-minibuffer-insert-face  'vip-minibuffer-insert-face'
  149. `vip-minibuffer-emacs-face  'vip-minibuffer-emacs-face'
  150.      These faces control the appearance of the minibuffer text in the
  151.      corresponding Viper states. For heavy-duty customization, consult
  152.      the Lisp Reference to Emacs. You can also take a look how these
  153.      faces are defined in `viper.el'.
  154.  
  155.      However, on a color workstation, the following method usually
  156.      suffices:
  157.           (set-face-foreground vip-minibuffer-vi-face "blue")
  158.           (set-face-background vip-minibuffer-emacs-face "orchid")
  159.      This will make a blue foreground in the Minibuffer when it is in Vi
  160.      state; its background will turn to orchid when it switches to
  161.      Emacs state.
  162.  
  163.      Note that only the text you type in is affected by the above faces.
  164.      Prompts and Minibuffer messages are not affected.
  165.  
  166.      Purists who do not like adornments in the minibuffer can always
  167.      zap them by putting
  168.           (copy-face 'default 'vip-minibuffer-vi-face)
  169.           (copy-face 'default 'vip-minibuffer-insert-face)
  170.           (copy-face 'default 'vip-minibuffer-emacs-face)
  171.      in the `~/.vip' file. However, in that case, the user will not
  172.      have any indication of the current Viper state in the minibuffer.
  173.      (This is important if the user accidentally switches to another
  174.      Viper state by typing `ESC' or `C-z'.
  175.  
  176.    Viper provides some support for multi-file documents and programs.
  177. If a document consists of several files we can designate one of them as
  178. a master and put the following at the end of that file:
  179.      ;;; Local Variables:
  180.      ;;; eval: (vip-setup-master-buffer "file1" "file2" "file3" "file5" "file5")
  181.      ;;; End:
  182.  
  183. where `file1' to `file5' are names of files related to the master file.
  184. Next time, when the master file is visited, the command
  185. `vip-setup-master-buffer' will be evaluated and the above files will be
  186. associated with the master file. Then, the new Ex command
  187. `:RelatedFile' (abbr. `:R') will display files 1 to 5 one after
  188. another, so you can edit them. If a file is not in any Emacs buffer, it
  189. will be visited.  The command `PreviousRelatedFile' (abbr., `:P') goes
  190. through the file list in the opposite direction.
  191.  
  192.    These commands are akin to `:n' and `:N', but they allow the user to
  193. focus on relevant files only.
  194.  
  195.    Note that only the master file needs to have the aforementioned
  196. block of commands. Also, ";;;" above can be replaced by some other
  197. markers. Semicolon is good for Lisp programs, since it is considered a
  198. comment designator there. For LaTeX, this could be "%%%", and for C the
  199. above block should be commented out.
  200.  
  201.    Even though these commands are sometimes useful, they are no
  202. substitute for the powerful *tag table* facility of Emacs. Viper's
  203. `:tag' command in a primitive interface to Emacs tags. *Note Tags:
  204. (emacs)Tags, for more information on tags.
  205.  
  206.    The following two commands are normally bound to a mouse click and
  207. are part of Viper. They work only if Emacs runs as an application under
  208. X Windows (or under some other window system for which a port of Emacs
  209. 19 is available). Clicking the mouse when Emacs is invoked in an Xterm
  210. window (using `emacs -nw') will do no good.
  211.  
  212. `M-S-mouse-1 (Emacs)'
  213. `meta shift button1up (XEmacs)'
  214.      Holding Meta and Shift while clicking mouse button 1 will initiate
  215.      search for a region under the mouse pointer (defined below).  This
  216.      command can take a prefix argument, which indicates the occurrence
  217.      of the pattern to search for.
  218.  
  219.      Note: Viper binds this mouse action only if it is not already
  220.      bound to something else. If you want to use this feature and
  221.      `M-S-mouse-1' is already used for something else, you can rebind
  222.      mouse-search as, for example, in the following example:
  223.           (global-set-key [M-mouse-1] 'vip-mouse-click-search-word)
  224.           (global-set-key [M-down-mouse-1] 'vip-mouse-catch-frame-switch)
  225.      This would bind mouse search to the action invoked by pressing the
  226.      Meta key and clicking mouse button 1. Note: if
  227.      `vip-mouse-click-search-word' is bound to an action, then
  228.      `vip-mouse-catch-frame-switch' must be bound to a down-action, as
  229.      shown in the above example.
  230.  
  231.      In XEmacs, you can change bindings as follows:
  232.           (global-set-key [(meta control button1up)]
  233.                           'vip-mouse-click-search-word)
  234.           (global-set-key [(meta control button1)]
  235.                           'vip-mouse-catch-frame-switch)
  236.      if, say, you prefer to hold both meta and control while clicking.
  237.  
  238.      Like in Emacs, there are special rules for binding these
  239.      functions: the first must be bound to a button-up event while the
  240.      second must be bound to a button-event (which is XEmacs'
  241.      equivalent of a down-mouse event).  Also, in Emacs, the
  242.      double-click and triple-click actions for the same button
  243.      (`double-S-mouse-1', etc., if the above default binding is used)
  244.      should not be bound (or it should be bound to the same function,
  245.      `vip-mouse-click-search-word').
  246.  
  247.      The region that is chosen as a pattern to search for is determined
  248.      as follows. If search is invoked via a single click, Viper chooses
  249.      the region that lies between the beginning of the "word" under the
  250.      pointer ("word" is understood in Vi sense) and the end of that
  251.      word.  The only difference with Vi's words is that in Lisp major
  252.      modes `-' is considered an alphanumeric symbol. This is done for
  253.      the convenience of working with Lisp symbols, which often have an
  254.      `-' in them.  Also, if you click on a non-alphanumeric character
  255.      that is not a word separator (in Vi sense) then this character
  256.      will also be considered alphanumeric, provided that it is adjacent
  257.      (from either side) to an alphanumeric character.  This useful
  258.      feature gives added control over the patterns selected by the
  259.      mouse click.
  260.  
  261.      On a double-click, the region is determined by the beginning of
  262.      the current Vi's "Word" (i.e., the largest non-separator chunk of
  263.      text) and the End of that "Word" (as determined by the `E'
  264.      command).
  265.  
  266.      On a triple-click, the region consists of the entire line where
  267.      the click occurred with all leading and trailing spaces and tabs
  268.      removed.
  269.  
  270. `M-S-mouse-2 (Emacs)'
  271. `meta shift button2up (XEmacs)'
  272.      Holding Meta and Shift while clicking mouse button 2 will insert
  273.      the region surrounding the mouse pointer.  The rules defining this
  274.      region are the same as for mouse-search.  This command takes an
  275.      optional prefix argument, which indicates how many such regions to
  276.      snarf from the buffer and insert.  (In case of a triple-click, the
  277.      prefix argument is ignored.)
  278.  
  279.      Note: Viper binds this mouse action only if it not already bound to
  280.      something else. If you want to use this feature and `S-mouse-2' is
  281.      already used for something else, you can rebind mouse-insert as
  282.      follows:
  283.           (global-set-key [M-mouse-2] 'vip-mouse-click-insert-word)
  284.           (global-set-key [M-down-mouse-2] 'vip-mouse-catch-frame-switch)
  285.      In XEmacs, you can change the bindings as follows:
  286.           (global-set-key [(meta control button2up)]
  287.                           'vip-mouse-click-insert-word)
  288.           (global-set-key [(meta control button2)]
  289.                           'vip-mouse-catch-frame-switch)
  290.  
  291. `vip-multiclick-timeout'
  292.      This variable controls the rate at which double-clicking must
  293.      occur for the purpose of mouse search and mouse insert. By
  294.      default, this is set to `double-click-time' in Emacs and to
  295.      `mouse-track-multi-click-time' milliseconds in XEmacs.
  296.  
  297.    Note: The above functions search and insert in the selected window of
  298. the latest active frame. This means that you can click in another
  299. window or another frame and have search or insertion done in the frame
  300. and window you just left.  This lets one use these functions in a
  301. multi-frame configuration.  However, this may require some getting used
  302. to. For instance, if you are typing in a frame, A, and then move the
  303. mouse to frame B and click to invoke mouse search, search (or
  304. insertion) will be performed in frame A. To perform search/insertion in
  305. frame B, you will first have to shift focus there, which doesn't happen
  306. until you type a character or perform some other action in frame
  307. B--mouse search doesn't shift focus (in XEmacs, to shift focus to frame
  308. B, you will have to select this frame with a mouse, by clicking.
  309.  
  310.    If you decide that you don't like the above feature and always want
  311. search/insertion be performed in the frame where the click occurs, don't
  312. bind (and unbind, if necessary) `vip-mouse-catch-frame-switch' from the
  313. mouse event it is bound to.
  314.  
  315.    Mouse search is integrated with Vi-style search, so you can repeat
  316. it with `n' and `N'. It should be also noted that, while
  317. case-sensitivity of search in Viper is controlled by the variable
  318. `vip-case-fold-search', the case of mouse search is controlled by the
  319. Emacs variable `case-fold-search', which may be set differently from
  320. `vip-case-fold-search'. Therefore, case-sensitivity of mouse search may
  321. be different from that of the usual Vi-style search.
  322.  
  323.    Finally, if the way Viper determines the word to be searched for or
  324. to be inserted is not what you want, there is a variable,
  325. `vip-surrounding-word-function', which can be changed to indicate
  326. another function for snarfing words out of the buffer. The catch is that
  327. you will then have to write such a function and make it known to your
  328. Emacs. The function `vip-surrounding-word' in `viper.el' can be used as
  329. a guiding example.
  330.  
  331. 
  332. File: viper,  Node: Vi Macros,  Prev: Viper Specials,  Up: Customization
  333.  
  334. Vi Macros
  335. =========
  336.  
  337.    Viper supports much enhanced Vi-style macros and also facilitates
  338. the use of Emacs-style macros.  To define a temporary macro, it is
  339. generally more convenient to use Emacs keyboard macro facility. Emacs
  340. keyboard macros are usually defined anonymously, and the latest macro
  341. can be executed by typing `C-x e' (or `*', if Viper is in Vi state). If
  342. you need to use several temporary macros, Viper lets you save them to a
  343. register (a lowercase letter); such macros can then be executed by
  344. typing `@a' in Vi state (if a macro was previously saved in register
  345. `a').  *Note Macros and Registers::, for details.
  346.  
  347.    If, however, you need to use a macro regularly, it must be given a
  348. permanent name and saved. Emacs manual explains how to do this, but
  349. invocation of named Emacs macros is quite different from Vi's. First,
  350. invocation of permanent Emacs macros takes time because of the extra
  351. keys.  Second, binding such macros to function keys, for fast access,
  352. hogs valuable real estate on the keyboard.
  353.  
  354.    Vi-style macros are better in that respect, since Vi lets the user
  355. overload the meaning of key sequences: keys typed in fast succession
  356. are treated specially, if this key sequence is bound to a macro.
  357.  
  358.    Viper provides keyboard macros through the usual Ex commands, `:map'
  359. and `:map!'. Vi-style macros are much more powerful in Viper than they
  360. are in the original Vi and in other emulators. This is because Viper
  361. implements an enhanced vi-style interface to the powerful Emacs
  362. keyboard macro facility.
  363.  
  364.    First, any Emacs command can be executed while defining a macro, not
  365. just the Vi commands. In particular, the user can invoke Emacs commands
  366. via `M-x command-name' or by pressing various function keys on the
  367. keyboard. One can even use the mouse, although this is usually not
  368. useful and is not recommended (and macros defined with the use of the
  369. mouse cannot be saved in command history and in the startup file, for
  370. future use).
  371.  
  372.    Macros defined by mixing Vi and Emacs commands are represented as
  373. vectors. So, don't be confused when you see one (usually through the
  374. history of Ex commands). For instance, if `gg' is defined by typing
  375. `l', the up-arrow key and `M-x next-line', its definition will look as
  376. follows in Emacs (in XEmacs, it looks slightly different, see below):
  377.  
  378.      [l up (meta x) n e x t - l i n e return]
  379.  
  380.    Second, Viper macros are defined in a WYSIWYG style. This means that
  381. commands are executed as you type them, so you can see precisely what is
  382. being defined.  Third, macros can be bound to arbitrary sequences of
  383. keys, not just to printable keys. For instance, one can define a macro
  384. that will be invoked by hitting `f3' then `f2' function keys. (The keys
  385. `delete' and `backspace' are excluded; also, a macro invocation
  386. sequence can't start with ESC. Some other keys, such as `f1' and
  387. `help', can't be bound to macros under Emacs (not XEmacs), since they
  388. are bound in `key-translation-map', which overrides any other binding
  389. the user gives to keys. In general, keys that have a binding in
  390. `key-translation-map' can't be bound to a macro.)
  391.  
  392.    Fourth, in Viper, one can define macros that are specific to a given
  393. buffer, a given major mode, or macros that are defined for all buffers.
  394. In fact, the same macro name can have several different definitions:
  395. one global, several definitions for various major modes, and
  396. definitions for various specific buffers. Buffer-specific definitions
  397. override mode-specific definitions, which, in turn, override global
  398. definitions.
  399.  
  400.    As if all that is not enough, Viper (through its interface to Emacs
  401. macros) lets the user define keyboard macros that ask for confirmation
  402. or even prompt the user for input and then continue. To do this, one
  403. should type `C-x q' (for confirmation) or `C-u C-x q' (for prompt).
  404. For details, *note Customization: (emacs)Kbd Macro Query.
  405.  
  406.    When the user finishes defining a macro (which is done by typing
  407. `C-x)' -- a departure from Vi), you will be asked whether you want this
  408. macro to be global, mode-specific, or buffer-specific. You will also be
  409. given a chance to save the macro in your `~/.vip' file.  This is the
  410. easiest way to save a macro and make it permanently available. If you
  411. work your startup files with bare hands, here is how Viper saves the
  412. above macro so that it will be available in Viper's Insert state (and
  413. Replace state) in buffer `my-buf' only:
  414.  
  415.       (vip-record-kbd-macro "gg" 'insert-state
  416.              [l up (meta x) n e x t - l i n e return]
  417.              "my-buf")
  418.  
  419. To do the same for Vi state and all buffers with the major mode
  420. `cc-mode', use:
  421.  
  422.       (vip-record-kbd-macro "gg" 'vi-state
  423.              [l up (meta x) n e x t - l i n e return]
  424.              'cc-mode)
  425.  
  426. Both macro names and macro definitions are vectors of symbols that
  427. denote keys on the keyboard. Some keys, like `\', ` ', or digit-keys
  428. must be escaped with a backslash. Modified keys are represented as
  429. lists. For instance, holding Meta and Control and pressing `f4' is
  430. represented as `(control meta f4)'.  If all members of a vectors are
  431. printable characters (or sequences, such as `\e', `\t', for ESC and
  432. TAB), then they can also be represented as strings:
  433.  
  434.       (vip-record-kbd-macro "aa" 'vi-state  "aaa\e"  "my-buffer")
  435.  
  436. Thus, typing `aa' fast in Vi state will switch Viper to Insert state
  437. (due to the first `a'), insert `aa', and then it will switch back to Vi
  438. state. All this will take effect only in the buffer named `my-buffer'.
  439.  
  440.    Note that the last argument to `vip-record-kbd-macro' must be either
  441. a string (a buffer name), a symbol representing a major mode, or `t';
  442. the latter says that the macro is to be defined for all buffers (which
  443. is how macros are defined in original Vi).
  444.  
  445.    For convenience, Viper also lets you define Vi-style macros in its
  446. Emacs state. There is no Ex command, like `:map' and `:map!' for doing
  447. this, but the user can include such a macro in the `~/.vip' file. The
  448. only thing is that the `vip-record-kbd-macro' command should specify
  449. `'emacs-state' instead of `'vi-state' or `'insert-state'.
  450.  
  451.    The user can get rid of a macro either by using the Ex commands
  452. `:unmap' and `:unmap!' or by issuing a call to `vip-unrecord-kbd-macro'.
  453. The latter is more powerful, since it can delete macros even in
  454. `'emacs-state'. However, `vip-unrecord-kbd-macro' is usually needed
  455. only when the user needs to get rid of the macros that are already
  456. predefined in Viper.  The syntax is:
  457.      (vip-unrecord-kbd-macro macro state)
  458.  
  459. The second argument must be `'vi-state', `'insert-state', or
  460. `'emacs-state'. The first argument is a name of a macro.  To avoid
  461. mistakes in specifying names of existing macros, type `M-x
  462. vip-describe-kbd-macros' and use a name from the list displayed by this
  463. command.
  464.  
  465.    If an error occurs during macro definition, Emacs aborts the
  466. process, and it must be repeated. This is analogous to Vi, except that
  467. in Vi the user doesn't know there is an error until the macro is
  468. actually run. All that means that in order for a definition to be
  469. successful, the user must do some simple planning of the process in
  470. advance, to avoid errors.  For instance, if you want to map `gg' to
  471. `llll' in Vi state, you must make sure that there is enough room on the
  472. current line. Since `l' moves the cursor forward, it may signal an
  473. error on reaching the end of line, which will abort the definition.
  474.  
  475.    These precautions are necessary only when defining macros; they will
  476. help avoid the need to redo the job. When macros are actually run, an
  477. error during the execution will simply terminate the current execution
  478. (but the macro will remain mapped).
  479.  
  480.    A macro name can be a string of characters or a vector of keys.  The
  481. latter makes it possible to define macros bound to, say, double-hits on
  482. a function key, such as `up' or `f13'.  This is very useful if you run
  483. out of function keys on your keyboard; it makes Viper macro facility a
  484. *keyboard doubler*, so to speak.
  485.  
  486.    Elsewhere (*Note Keybindings::, for details), we review the standard
  487. Emacs mechanism for binding function keys to commands.  For instance,
  488.  
  489.      (global-set-key [f13] 'repeat-complex-command)
  490.  
  491. binds the key f13 to the Emacs function that repeats the last minibuffer
  492. command. Under Viper, however, you may still use this key for additional
  493. purposes, if you bind, say, a double-hitting action for that key to some
  494. other function. Emacs doesn't allow the user to do that, but Viper does
  495. this through its keyboard macro facility. To do this, type `:map '
  496. first. When you are asked to enter a macro name, hit f13 twice,
  497. followed by RET or SPC.
  498.  
  499.    Emacs will now start the mapping process by actually executing Vi
  500. and Emacs commands, so that you could see what will happen each time the
  501. macro is executed. Suppose now we wanted to bind the key sequence `f13
  502. f13' to the command `eval-last-sexp'. To accomplish this, we can type
  503. `M-x eval-last-sexp' followed by `C-x )'.  If you answer positively to
  504. Viper's offer to save this macro in `~/.vip' for future uses, the
  505. following will be inserted in that file:
  506.  
  507.      (vip-record-kbd-macro [f16 f16] 'vi-state
  508.               [(meta x) e v a l - l a s t - s e x p]
  509.               'lisp-interaction-mode)
  510.  
  511.    To illustrate the above point, Viper provides two canned macros,
  512. which, by default, are bound to `[f12 \1]' and `[f12 \2]' (invoked by
  513. typing `f12' then `1' and `2', respectively).  These macros are useful
  514. shortcuts to Viper's command ring history.  The first macro will
  515. execute the second-last destructive command (the last one is executed
  516. by `.', as usual). The second macro executes the third-last command.
  517.  
  518.    If you need to go deeper into the command history, you will have to
  519. use other commands, as described earlier in this section; or you can
  520. bind, say, `f12 \3' like this:
  521.  
  522.      (vip-record-kbd-macro [f12 \3] 'vi-state
  523.                            [(meta x) r e p e a t - f r o m - h i s t o r y]
  524.                            t)
  525.  
  526.    Note that even though the macro uses the function key `f12', the key
  527. is actually free and can still be bound to some Emacs function via
  528. `define-key' or `global-set-key'.
  529.  
  530.    Viper allows the user to define macro names that are prefixes of
  531. other macros.  For instance, one can define `[[' and `[[[[' to be
  532. macros.  If you type the exact sequence of such keys and then pause,
  533. Viper will execute the right macro. However, if you don't pause and,
  534. say, type `[[[[text' then the conflict is resolved as follows. If only
  535. one of the key sequences, `[[' or `[[[[' has a definition applicable to
  536. the current buffer, then, in fact, there is no conflict and the right
  537. macro will be chosen. If both have applicable definitions, then the
  538. first one found will be executed. Usually this is the macro with a
  539. shorter name. So, in our case, `[[[[text' will cause the macro `[[' to
  540. be executed twice and then the remaining keys, `t e x t', will be
  541. processed.
  542.  
  543.    When defining macros using `:map' or `:map!', the user enters the
  544. actually keys to be used to invoke the macro. For instance, you should
  545. hit the actual key `f6' if it is to be part of a macro name; you do
  546. *not* write `f 6'. When entering keys, Viper displays them as strings or
  547. vectors (e.g., "abc" or [f6 f7 a]). The same holds for unmapping.
  548. Hitting TAB while typing a macro name in the `:unmap' or `:unmap!'
  549. command will cause name completion. Completions are displayed as
  550. strings or vectors.  However, as before, you don't actually type """,
  551. "[", or "]" that appear in the completions. These are meta-symbols that
  552. indicate whether the corresponding macro name is a vector or a string.
  553.  
  554.    One last difference from Vi: Vi-style keyboard macros cannot be
  555. defined in terms of other Vi-style keyboard macros (but named Emacs
  556. macros are OK).  More precisely, while defining or executing a macro,
  557. the special meaning of key sequences (as Vi macros) is ignored.  This
  558. is because it is all too easy to create an infinite loop in this way.
  559. Since Viper macros are much more powerful than Vi's it is impossible to
  560. detect such loops. In practice, this is not really a limitation but,
  561. rather, a feature.
  562.  
  563.    We should also note that Vi macros are disabled in the Minibuffer,
  564. which helps keep some potential troubles away.
  565.  
  566.    The rate at which the user must type keys in order for them to be
  567. recognized as a timeout macro is controlled by the variable
  568. `vip-fast-keyseq-timeout', which defaults to 200 milliseconds.
  569.  
  570.    For the most part, Viper macros defined in `~/.vip' can be shared
  571. between Emacs, XEmacs, and X and TTY modes.  However, macros defined via
  572. function keys may need separate definitions when XEmacs and Emacs have
  573. different names for the same keyboard key. For instance, the `Page Up'
  574. key may be known in Emacs as `prior' and in XEmacs as `pgup'.  The
  575. problem with TTY may be that the function keys there generate sequences
  576. of events instead of a single event (as under a window system).  Both
  577. Emacs and XEmacs mape some of these sequences back to the logical keys
  578. (e.g., the sequences generated by the arrow keys are mapped to `up',
  579. `left', etc.). However, not all function keys are mapped in this way.
  580. Macros that are bound to key sequences that contain such unmapped
  581. function keys have to be redefined for TTY's (and possibly for every
  582. type of TTY you may be using). To do this, start Emacs on an
  583. appropriate TTY device and define the macro using `:map', as usual.
  584.  
  585.    Finally, Viper provides a function that conveniently displays all
  586. macros currently defined. To see all macros along with their
  587. definitions, type `M-x vip-describe-kbd-macros'.
  588.  
  589. 
  590. File: viper,  Node: Commands,  Prev: Customization,  Up: Top
  591.  
  592.    Top
  593.  
  594. Commands
  595. ********
  596.  
  597.    This section is a semi-automatically bowdlerized version of the Vi
  598. reference created by
  599. `maart@cs.vu.nl' and others. It can be found on the Vi archives. Very
  600. little has been changed for Viper.
  601.  
  602. * Menu:
  603.  
  604. * Groundwork::            Textual Conventions and Viper basics
  605. * Text Handling::        Moving, Editing, Undoing.
  606. * Display::            Scrolling.
  607. * File and Buffer Handling::    Editing, Writing and Quitting.
  608. * Mapping::            Mapping Keys, Keyboard Macros
  609. * Shell Commands::        Accessing Shell Commands, Processing Text
  610. * Options::            Ex options, the `:set' commands
  611. * Emacs Related Commands::    Meta Keys, Windows
  612. * Mouse-bound Commands::        Search and insertion of text
  613.  
  614. 
  615. File: viper,  Node: Groundwork,  Next: Text Handling,  Prev: Commands,  Up: Commands
  616.  
  617. Groundwork
  618. ==========
  619.  
  620.    The VI command set is based on the idea of combining motion commands
  621. with other commands. The motion command is used as a text region
  622. specifier for other commands.  We classify motion commands into "point
  623. commands" and "line commands".
  624.  
  625.    The point commands are:
  626.  
  627.      `h', `l', `0',  `$', `w', `W', `b', `B', `e', `E', `(', `)', `/',
  628.      `?', ``', `f', `F', `t', `T', `%', `;', `,', `^'
  629.  
  630.    The line commands are:
  631.  
  632.      `j', `k', `+', `-', `H', `M', `L', `{', `}', `G', `'',  `[[',
  633.      `]]', `[]'
  634.  
  635. Text Deletion Commands (*Note Deleting Text::), Change commands (*Note
  636. Changing Text::), even Shell Commands (*Note Shell Commands::) use
  637. these commands to describe a region of text to operate on.
  638.  
  639.    Viper adds two region descriptors, `r' and `R'. These describe the
  640. Emacs regions (*Note Basics::), but they are not movement commands.
  641.  
  642.    The command description uses angle brackets `<>' to indicate
  643. metasyntactic variables, since the normal conventions of using simple
  644. text can be confusing with Viper where the commands themselves are
  645. characters. Watch out where `<' shift commands and `<count>' are
  646. mentioned together!!!
  647.  
  648.    `<move>' refers to the above movement commands, and `<a-z>' refers
  649. to registers or textmarkers from `a' to `z'. Note that the `<move>'  is
  650. described by full move commands, that is to say they will take counts,
  651. and otherwise behave like normal move commands.  `<address>' refers to
  652. Ex line addresses, which include
  653.  
  654. `. <No address>'
  655.      Current line
  656.  
  657. `.+n .-n'
  658.      Add or subtract for current line
  659.  
  660. `number'
  661.      Actual line number, use `.=' to get the line number
  662.  
  663. `'<a-z>'
  664.      Textmarker
  665.  
  666. `$'
  667.      Last line
  668.  
  669. `x,y'
  670.      Where x and y are one of the above
  671.  
  672. `%'
  673.      For the whole file, same as (1,$).
  674.  
  675. `/pat/'
  676. `?pat?'
  677.      Next or previous line with pattern pat
  678.  
  679.    Note that `%' is used in Ex commands to mean current file. If you
  680. want a `%' in your command, it must be escaped as `\%'.  Similarly, `#'
  681. expands to the previous file. The previous file is the first file in
  682. `:args' listing. This defaults to previous window in the VI sense if
  683. you have one window only.
  684.  
  685. Others like `<args> -- arguments', `<cmd> -- command' etc.  should be
  686. fairly obvious.
  687.  
  688. Common characters referred to include:
  689.  
  690. `<sp>'
  691.      Space
  692.  
  693. `<ht>'
  694.      Tab
  695.  
  696. `<lf>'
  697.      Linefeed
  698.  
  699. `<esc>'
  700.      Escape
  701.  
  702. `<cr>'
  703.      Return, Enter
  704.  
  705.    We also use `word' for alphanumeric/non-alphanumeric words, and
  706. `WORD' for whitespace delimited words. `char' refers to any ASCII
  707. character, `CHAR' to non-whitespace character.  Brackets `[]' indicate
  708. optional parameters; `<count>' also optional, usually defaulting to 1.
  709. Brackets are elided for `<count>' to eschew obfuscation.
  710.  
  711.    Viper's idea of Vi's words is slightly different from Vi. First,
  712. Viper words understand Emacs symbol tables. Therefore, all symbols
  713. declared to be alphanumeric in a symbol table can automatically be made
  714. part of the Viper word.  This is useful when, for instance, editing
  715. text containing European, Cyrillic, etc., letters.
  716.  
  717.    Second, Viper lets you depart from Vi's idea of a word by changing
  718. the value of `vip-syntax-preference'. By default, this variable is set
  719. to `'strict-vi', which means that alphanumeric symbols are exactly as
  720. in Vi.  However, if the value is `'reformed-vi' then alphanumeric
  721. symbols will be those specified by the current Emacs syntax table (which
  722. may be different for different major modes) plus the underscore symbol
  723. `_'. The user can also specify the value `'emacs', which would make
  724. Viper use exactly the Emacs notion of word. In particular, the
  725. underscore may not be part of a word. Finally, if
  726. `vip-syntax-preference' is set to `'extended', Viper words would
  727. consist of characters that are classified as alphanumeric *or* as parts
  728. of symbols. This is convenient for writing programs and in many other
  729. situations.
  730.  
  731.    `vip-syntax-preference' is a local variable, so it can have different
  732. values for different major modes. For instance, in programming modes it
  733. can have the value `'extended'. In text modes where words contain
  734. special characters, such as European (non-English) letters, Cyrillic
  735. letters, etc., the value can be `'reformed-vi' or `'emacs'.
  736.  
  737.    Changes to `vip-syntax-preference' should be done in the hooks to
  738. various major modes. Furthermore, for these changes to take effect, you
  739. should execute `(vip-update-alphanumeric-class)' right after changing
  740. the value of `vip-syntax-preference'.
  741.  
  742.    The above discussion concerns only the movement commands. In regular
  743. expressions, words remain the same as in Emacs.  That is, the
  744. expressions `\w', `\>', `\<', etc., use Emacs' idea of what is a word,
  745. and they don't look into the value of variable `vip-syntax-preference'.
  746. This is because Viper doesn't change syntax tables in order to not
  747. thwart the various major modes that set these tables.
  748.  
  749.    The usual Emacs convention is used to indicate Control Characters,
  750. i.e C-h for Control-h. *Do not confuse this to mean the separate
  751. characters C - h!!!* The `^' is itself, never used to indicate a
  752. Control character.
  753.  
  754. 
  755. File: viper,  Node: Text Handling,  Next: Display,  Prev: Groundwork,  Up: Commands
  756.  
  757. Text Handling
  758. =============
  759.  
  760. * Menu:
  761.  
  762. * Move Commands::        Moving, Searching
  763. * Marking::                Textmarkers in Viper and the Emacs Mark.
  764. * Appending Text::        Text insertion, Shifting, Putting
  765. * Editing in Insert State::    Autoindent, Quoting etc.
  766. * Deleting Text::        Deleting
  767. * Changing Text::        Changing, Replacement, Joining
  768. * Search and Replace::        Searches, Query Replace, Pattern Commands
  769. * Yanking::            Yanking, Viewing Registers
  770. * Undoing::            Multiple Undo, Backups
  771.  
  772. 
  773. File: viper,  Node: Move Commands,  Next: Marking,  Up: Text Handling
  774.  
  775. Move Commands
  776. -------------
  777.  
  778. `<count>  h  C-h'
  779.      <count> chars to the left.
  780.  
  781. `<count>  j  <lf> C-n'
  782.      <count> lines downward.
  783.  
  784. `<count>  l  <sp>'
  785.      <count> chars to the right.
  786.  
  787. `<count>  k  C-p'
  788.      <count> lines upward.
  789.  
  790. `<count>  $'
  791.      To the end of line <count> from the cursor.
  792.  
  793. `<count>  ^'
  794.      To the first CHAR <count> - 1 lines lower.
  795.  
  796. `<count>  -'
  797.      To the first CHAR <count> lines higher.
  798.  
  799. `<count>  +  <cr>'
  800.      To the first CHAR <count> lines lower.
  801.  
  802. `0'
  803.      To the first char of the line.
  804.  
  805. `<count> |'
  806.      To column <count>
  807.  
  808. `<count>  f<char>'
  809.      <count> <char>s to the right (find).
  810.  
  811. `<count>  t<char>'
  812.      Till before <count> <char>s to the right.
  813.  
  814. `<count>  F<char>'
  815.      <count> <char>s to the left.
  816.  
  817. `<count>  T<char>'
  818.      Till after <count> <char>s to the left.
  819.  
  820. `<count>  ;'
  821.      Repeat latest `f t F T' <count> times.
  822.  
  823. `<count>  ,'
  824.      Repeat latest `f t F T' <count> times in opposite direction.
  825.  
  826. `<count>  w'
  827.      <count> words forward.
  828.  
  829. `<count>  W'
  830.      <count> WORDS forward.
  831.  
  832. `<count>  b'
  833.      <count> words backward.
  834.  
  835. `<count>  B'
  836.      <count> WORDS backward.
  837.  
  838. `<count>  e'
  839.      To the end of word <count> forward.
  840.  
  841. `<count>  E'
  842.      To the end of WORD <count> forward.
  843.  
  844. `<count>  G'
  845.      Go to line <count> (default end-of-file).
  846.  
  847. `<count>  H'
  848.      To line <count> from top of the screen (home).
  849.  
  850. `<count>  L'
  851.      To line <count> from bottom of the screen (last).
  852.  
  853. `M'
  854.      To the middle line of the screen.
  855.  
  856. `<count>  )'
  857.      <count> sentences forward.
  858.  
  859. `<count>  ('
  860.      <count> sentences backward.
  861.  
  862. `<count>  }'
  863.      <count> paragraphs forward.
  864.  
  865. `<count>  {'
  866.      <count> paragraphs backward.
  867.  
  868. `<count>  ]]'
  869.      To the <count>th heading.
  870.  
  871. `<count>  [['
  872.      To the <count>th previous heading.
  873.  
  874. `<count>  []'
  875.      To the end of <count>th heading.
  876.  
  877. `m<a-z>'
  878.      Mark the cursor position with a letter.
  879.  
  880. ``<a-z>'
  881.      To the mark.
  882.  
  883. `'<a-z>'
  884.      To the first CHAR of the line with the mark.
  885.  
  886. `[<a-z>'
  887.      Show contents of textmarker.
  888.  
  889. `]<a-z>'
  890.      Show contents of register.
  891.  
  892. ```'
  893.      To the cursor position before the latest absolute jump (of which
  894.      are examples `/' and `G').
  895.  
  896. `'''
  897.      To the first CHAR of the line on which the cursor was placed
  898.      before the latest absolute jump.
  899.  
  900. `<count>  /<string>'
  901.      To the <count>th occurrence of <string>.
  902.  
  903. `<count>  /<cr>'
  904.      To the <count>th occurrence of <string> from previous `/ or ?'.
  905.  
  906. `<count>  ?<string>'
  907.      To the <count>th previous occurrence of <string>.
  908.  
  909. `<count>  ?<cr>'
  910.      To the <count>th previous occurrence of <string> from previous `?
  911.      or /'.
  912.  
  913. `n'
  914.      Repeat latest `/' `?' (next).
  915.  
  916. `N'
  917.      Repeat latest search in opposite direction.
  918.  
  919. `C-c /'
  920.      Without a prefix argument, this command toggles
  921.      case-sensitive/case-insensitive search modes and plain
  922.      vanilla/regular expression search. With the prefix argument 1,
  923.      i.e., `1 C-c /', this toggles case-sensitivity; with the prefix
  924.      argument 2, toggles plain vanilla search and search using regular
  925.      expressions. *Note Viper Specials::, for alternative ways to invoke
  926.      this function.
  927.  
  928. `%'
  929.      Find the next bracket and go to its match.
  930.  
  931. 
  932. File: viper,  Node: Marking,  Next: Appending Text,  Prev: Move Commands,  Up: Text Handling
  933.  
  934. Marking
  935. -------
  936.  
  937.    Emacs mark is referred to in the region specifiers `r' and `R'.
  938. *Note Emacs Preliminaries:: and *note Basics::. for explanation. Also
  939. see *Note Mark: (emacs)Mark, for an explanation of the Emacs mark ring.
  940.  
  941. `m<a-z>'
  942.      Mark the current file and position with the specified letter.
  943.  
  944. `m .'
  945.      Set the Emacs mark (*Note Emacs Preliminaries::) at point.
  946.  
  947. `m <'
  948.      Set the Emacs mark at beginning of buffer.
  949.  
  950. `m >'
  951.      Set the Emacs mark at end of buffer.
  952.  
  953. `m ,'
  954.      Jump to the Emacs mark.
  955.  
  956. `:mark <char>'
  957.      Mark position with text marker named <char>. This is an Ex command.
  958.  
  959. `:k <char>'
  960.      Same as `:mark'.
  961.  
  962. ```'
  963.      Exchange point and mark.
  964.  
  965. `'''
  966.      Exchange point and mark and go to the first CHAR on line.
  967.  
  968. `'<a-z>'
  969.      Go to specified Viper mark.
  970.  
  971. `'
  972.      Go to specified Viper mark and go to the first CHAR on line.
  973.  
  974. 
  975. File: viper,  Node: Appending Text,  Next: Editing in Insert State,  Prev: Marking,  Up: Text Handling
  976.  
  977. Appending Text
  978. --------------
  979.  
  980.    *Note Options:: to see how to change tab and shiftwidth size. See
  981. the GNU Emacs manual, or try `C-ha tabs' (If you have turned Emacs help
  982. on).  Check out the variable `indent-tabs-mode' to put in just spaces.
  983. Also see options for word-wrap.
  984.  
  985. `<count>  a'
  986.      <count> times after the cursor.
  987.  
  988. `<count>  A'
  989.      <count> times at the end of line.
  990.  
  991. `<count>  i'
  992.      <count> times before the cursor (insert).
  993.  
  994. `<count>  I'
  995.      <count> times before the first CHAR of the line
  996.  
  997. `<count>  o'
  998.      On a new line below the current (open).  The count is only useful
  999.      on a slow terminal.
  1000.  
  1001. `<count>  O'
  1002.      On a new line above the current.  The count is only useful on a
  1003.      slow terminal.
  1004.  
  1005. `<count>  ><move>'
  1006.      Shift the lines described by <count><move> one shiftwidth to the
  1007.      right (layout!).
  1008.  
  1009. `<count>  >>'
  1010.      Shift <count> lines one shiftwidth to the right.
  1011.  
  1012. `<count>  ["<a-z1-9>]p'
  1013.      Put the contents of the (default undo) buffer <count> times after
  1014.      the cursor. The register will be automatically downcased.
  1015.  
  1016. `<count>  ["<a-z1-9>]P'
  1017.      Put the contents of the (default undo) buffer <count> times before
  1018.      the cursor. The register will
  1019.  
  1020. `[<a-z>'
  1021.      Show contents of textmarker.
  1022.  
  1023. `]<a-z>'
  1024.      Show contents of register.
  1025.  
  1026. `<count>  .'
  1027.      Repeat previous command <count> times. For destructive commands as
  1028.      well as undo.
  1029.  
  1030. `f1 1 and f1 2'
  1031.      While `.' repeats the last destructive command, these two macros
  1032.      repeat the second-last and the third-last destructive commands.
  1033.      *Note Vi Macros::, for more information on Vi macros.
  1034.  
  1035. `C-c M-p and C-c M-n'
  1036.      In Vi state, these commands help peruse the history of Vi's
  1037.      destructive commands.  Successive typing of `C-c M-p' causes Viper
  1038.      to search the history in the direction of older commands, while
  1039.      hitting `C-c M-n' does so in reverse order. Each command in the
  1040.      history is displayed in the Minibuffer. The displayed command can
  1041.      then be executed by typing ``.''.
  1042.  
  1043.      Since typing the above sequences of keys may be tedious, the
  1044.      functions doing the perusing can be bound to unused keyboard keys
  1045.      in the `~/.vip' file. *Note Viper Specials::, for details.
  1046.  
  1047. 
  1048. File: viper,  Node: Editing in Insert State,  Next: Deleting Text,  Prev: Appending Text,  Up: Text Handling
  1049.  
  1050. Editing in Insert State
  1051. -----------------------
  1052.  
  1053.    Minibuffer can be edited similarly to Insert state, and you can
  1054. switch between Insert/Replace/Vi states at will.  Some users prefer
  1055. plain Emacs feel in the Minibuffer. To this end, set
  1056. VIP-VI-STYLE-IN-MINIBUFFER to `nil'.
  1057.  
  1058. `C-v'
  1059.      Deprive the next char of its special meaning (quoting).
  1060.  
  1061. `C-h'
  1062.      One char back.
  1063.  
  1064. `C-w'
  1065.      One word back.
  1066.  
  1067. `C-u'
  1068.      Back to the begin of the change on the current line.
  1069.  
  1070. 
  1071. File: viper,  Node: Deleting Text,  Next: Changing Text,  Prev: Editing in Insert State,  Up: Text Handling
  1072.  
  1073. Deleting Text
  1074. -------------
  1075.  
  1076.    There is one difference in text deletion that you should be aware
  1077. of. This difference comes from Emacs and was adopted in Viper because
  1078. we find it very useful. In Vi, if you delete a line, say, and then
  1079. another line, these two deletions are separated and are put back
  1080. separately if you use the `p' command. In Emacs (and Viper), successive
  1081. series of deletions that are *not interrupted* by other commands are
  1082. lumped together, so the deleted text gets accumulated and can be put
  1083. back as one chunk. If you want to break a sequence of deletions so that
  1084. the newly deleted text could be put back separately from the previously
  1085. deleted text, you should perform a non-deleting action, e.g., move the
  1086. cursor one character in any direction.
  1087.  
  1088. `<count>  x'
  1089.      Delete <count> chars under and after the cursor.
  1090.  
  1091. `<count>  X'
  1092.      Delete <count> chars before the cursor.
  1093.  
  1094. `<count>  d<move>'
  1095.      Delete from point to endpoint of <count><move>.
  1096.  
  1097. `<count>  dd'
  1098.      Delete <count> lines.
  1099.  
  1100. `D'
  1101.      The rest of the line.
  1102.  
  1103. `<count>  <<move>'
  1104.      Shift the lines described by <count><move> one shiftwidth to the
  1105.      left (layout!).
  1106.  
  1107. `<count>  <<'
  1108.      Shift <count> lines one shiftwidth to the left.
  1109.  
  1110. 
  1111. File: viper,  Node: Changing Text,  Next: Search and Replace,  Prev: Deleting Text,  Up: Text Handling
  1112.  
  1113. Changing Text
  1114. -------------
  1115.  
  1116. `<count>  r<char>'
  1117.      Replace <count> chars by <char> - no <esc>.
  1118.  
  1119. `<count>  R'
  1120.      Overwrite the rest of the line, appending change COUNT - 1 times.
  1121.  
  1122. `<count>  s'
  1123.      Substitute <count> chars.
  1124.  
  1125. `<count>  S'
  1126.      Change <count> lines.
  1127.  
  1128. `<count>  c<move>'
  1129.      Change from begin to endpoint of <count><move>.
  1130.  
  1131. `<count>  cc'
  1132.      Change <count> lines.
  1133.  
  1134. `<count>  C'
  1135.      The rest of the line and <count> - 1 next lines.
  1136.  
  1137. `<count>  =<move>'
  1138.      Reindent the region described by move.
  1139.  
  1140. `<count>  ~'
  1141.      Switch lower and upper cases.
  1142.  
  1143. `<count>  J'
  1144.      Join <count> lines (default 2).
  1145.  
  1146. `:[x,y]s/<p>/<r>/<f>'
  1147.      Substitute (on lines x through y) the pattern <p> (default the
  1148.      last pattern) with <r>.  Useful flags <f> are `g' for `global'
  1149.      (i.e. change every non-overlapping occurrence of <p>) and `c' for
  1150.      `confirm' (type `y' to confirm a particular substitution, else `n'
  1151.      ).  Instead of `/' any punctuation CHAR unequal to <space> <tab>
  1152.      and <lf> can be used as delimiter.
  1153.  
  1154. `:[x,y]copy [z]'
  1155.      Copy text between `x' and `y' to the position after `z'.
  1156.  
  1157. `:[x,y]t [z]'
  1158.      Same as `:copy'.
  1159.  
  1160. `:[x,y]move [z]'
  1161.      Move text between `x' and `y' to the position after `z'.
  1162.  
  1163. `&'
  1164.      Repeat latest Ex substitute command, e.g.  `:s/wrong/good'.
  1165.  
  1166. `C-c /'
  1167.      Toggle case-sensitive search. With prefix argument, toggle
  1168.      vanilla/regular expression search.
  1169.  
  1170. `#c<move>'
  1171.      Change upper case characters in the region to lower case.
  1172.  
  1173. `#C<move>'
  1174.      Change lower case characters in the region to upper case.
  1175.  
  1176. `#q<move>'
  1177.      Insert specified string at the beginning of each line in the region
  1178.  
  1179. `C-c M-p and C-c M-n'
  1180.      In Insert and Replace states, these keys are bound to commands
  1181.      that peruse the history of the text previously inserted in other
  1182.      insert or replace commands. By repeatedly typing `C-c M-p' or `C-c
  1183.      M-n', you will cause Viper to insert these previously used strings
  1184.      one by one.  When a new string is inserted, the previous one is
  1185.      deleted.
  1186.  
  1187.      In Vi state, these keys are bound to functions that peruse the
  1188.      history of destructive Vi commands.  *Note Viper Specials::, for
  1189.      details.
  1190.  
  1191. 
  1192. File: viper,  Node: Search and Replace,  Next: Yanking,  Prev: Changing Text,  Up: Text Handling
  1193.  
  1194. Search and Replace
  1195. ------------------
  1196.  
  1197.    *Note Groundwork::, for Ex address syntax. *Note Options:: to see
  1198. how to get literal (non-regular-expression) search and how to stop
  1199. search from wrapping around.
  1200.  
  1201. `<count>  /<string>'
  1202.      To the <count>th occurrence of <string>.
  1203.  
  1204. `<count>  ?<string>'
  1205.      To the <count>th previous occurrence of <string>.
  1206.  
  1207. `<count>  g<move>'
  1208.      Search for the text described by move. (off by default)
  1209.  
  1210. `n'
  1211.      Repeat latest `/' `?' (next).
  1212.  
  1213. `N'
  1214.      Idem in opposite direction.
  1215.  
  1216. `%'
  1217.      Find the next bracket and go to its match
  1218.  
  1219. `:[x,y]g/<string>/<cmd>'
  1220.      Search globally [from line x to y] for <string> and execute the Ex
  1221.      <cmd> on each occurrence.
  1222.  
  1223. `:[x,y]v/<string>/<cmd>'
  1224.      Execute <cmd> on the lines that don't match.
  1225.  
  1226. `#g<move>'
  1227.      Execute the last keyboard macro for each line in the region.
  1228.      *Note Macros and Registers::, for more info.
  1229.  
  1230. `Q'
  1231.      Query Replace.
  1232.  
  1233. `:ta <name>'
  1234.      Search in the tags file where <name> is defined (file, line), and
  1235.      go to it.
  1236.  
  1237. `:[x,y]s/<p>/<r>/<f>'
  1238.      Substitute (on lines x through y) the pattern <p> (default the last
  1239.      pattern) with <r>.  Useful flags <f> are `g' for `global' (i.e.
  1240.      change every non-overlapping occurrence of <p>) and `c' for
  1241.      `confirm' (type `y' to confirm a particular substitution, else
  1242.      `n').  Instead of `/' any punctuation CHAR unequal to <space>
  1243.      <tab> and <lf> can be used as delimiter.
  1244.  
  1245. `&'
  1246.      Repeat latest Ex substitute command, e.g. `:s/wrong/good'.
  1247.  
  1248. 
  1249. File: viper,  Node: Yanking,  Next: Undoing,  Prev: Search and Replace,  Up: Text Handling
  1250.  
  1251. Yanking
  1252. -------
  1253.  
  1254. `<count>  y<move>'
  1255.      Yank from begin to endpoint of <count><move>.
  1256.  
  1257. `<count>  "<a-z>y<move>'
  1258.      Yank from begin to endpoint of <count><move> to register.
  1259.  
  1260. `<count>  "<A-Z>y<move>'
  1261.      Yank from begin to endpoint of <count><move> and append to
  1262.      register.
  1263.  
  1264. `<count>  yy'
  1265.      <count> lines.
  1266.  
  1267. `<count>  Y'
  1268.      Idem (should be equivalent to `y$' though).
  1269.  
  1270. `m<a-z>'
  1271.      Mark the cursor position with a letter.
  1272.  
  1273. `[<a-z>'
  1274.      Show contents of textmarker.
  1275.  
  1276. `]<a-z>'
  1277.      Show contents of register.
  1278.  
  1279. `<count>  ["<a-z1-9>]p'
  1280.      Put the contents of the (default undo) buffer <count> times after
  1281.      the cursor. The register will be automatically downcased.
  1282.  
  1283. `<count>  ["<a-z1-9>]P'
  1284.      Put the contents of the (default undo) buffer <count> times before
  1285.      the cursor. The register will
  1286.  
  1287. 
  1288. File: viper,  Node: Undoing,  Prev: Yanking,  Up: Text Handling
  1289.  
  1290. Undoing
  1291. -------
  1292.  
  1293. `u U'
  1294.      Undo the latest change.
  1295.  
  1296. `.'
  1297.      Repeat undo.
  1298.  
  1299. `:q!'
  1300.      Quit Vi without writing.
  1301.  
  1302. `:e!'
  1303.      Re-edit a messed-up file.
  1304.  
  1305. `:rec'
  1306.      Recover file from autosave. Viper also creates backup files that
  1307.      have a `~' appended to them.
  1308.  
  1309.