Skip to content

Latest commit

 

History

History
156 lines (114 loc) · 5.64 KB

usage.md

File metadata and controls

156 lines (114 loc) · 5.64 KB

Usage

In all the following examples, the character | denotes the point.

Example 1: Navigation, deletion, evaluation and basic transformation

Commands

command binding
vilpy-special backtab
vilpy-ace-paren q
vilpy-ace-subword -
vilpy-ace-symbol f
vilpy-beginning-of-defun I
vilpy-delete C-d
vilpy-down j
vilpy-eval-buffer B
vilpy-eval e
vilpy-step-in l

Code

We will start with the following snippet:

(defun plus-one (n)
  (+ 1 n)
  (message "debug"))

(plus-one 2)

This will be the final result:

(def plus-two (n)
  (+ 2 n))

Steps

We start with this code. Note that the point is in the middle of defun.

(de|fun plus-one (n)
  (+ 1 n)
  (message "done"))

(plus-one 2)

Evaluating (plus-one 2)

  • Press backtab (that is, shift and tab) to move the point to the beginning of the defun and enter special mode.
  • First, evaluate the defun with e (vilpy-eval).
  • Then, use j (vilpy-down) and e for evaluating (plus-one 2) and getting 3.
  • Use k for getting back to the defun. Note that this entire sequence is equivalent to simply using B (vilpy-eval-buffer).

Change plus-one to plus-two

  • With the point in the beginning of the defun, press - (vilpy-ace-subword). This will display a letter in each subword, alphabetically, like (adefun bplus-cone ...). Press c for jumping to one, which will be marked.
  • Then, use C-d (vilpy-delete) for removing one and write two.
  • Press backtab for getting back to special mode.

Remove message

  • Use l (vilpy-step-in) three times for getting to the message form. This is equivalent to 3l. Alternatively, use q (vilpy-ace-paren) and d for directly jumping to message.
  • Then, press C-d (vilpy-delete) twice for removing the form and the blank line. The point will jump to the beginning of the defun.

Change (+ 1 n) to (+ 2 n)

  • Press f (vilpy-ace-symbol). This command will add a letter before each symbol. Use e for directly jumping to 1.
  • Use C-d for deleting it and write 2.
  • Use backtab for getting back to special mode.
  • I (vilpy-beginning-of-defun) for jumping to the beginning of the defun.
  • e for evaluating it.

Deleting (plus-one 2)

  • Finally, press j for moving the point to (plus-one 2).
  • C-d for deleting it.

Example 2: Killing, copying and yanking

Commands

command binding
vilpy-step-in l
vilpy-clone w
vilpy-down j
vilpy-ace-subword -
vilpy-special backtab
vilpy-up k
forward-char a
vilpy-space SPC
vilpy-kill C-k
vilpy-step-out h
vilpy-open-line-below o

Code

We will starting with this snippet of code:

(defun foo
  ()
  (do-bar)
  (do-baz (a) (b) (c)))

This will be the result:

(defun foo
  ()
  (with-foo do-bar)
  (do-foo)
  (do-baz (a))
  (a)))

Steps

Consider that the point starts just before defun, in special mode.

Insert (do-foo)

  • First, let's insert (do-foo) by duplicating (do-bar) and replacing bar.
  • Use l (vilpy-step-in) twice for getting to do-bar. This is equivalent to 2l or qc (vilpy-ace-paren followed by c).
  • Then, press w (vilpy-clone), which will duplicate (do-foo).
  • Use j (vilpy-down) for moving to the second (do-bar).
  • Press -b for marking bar and delete it with C-d. Type foo
  • Use backtab for getting back to special mode (that is, shift and tab).

Change (do-bar) to (with-foo do-bar)

  • Use k (vilpy-up) for getting to do-bar.
  • Then, press a (forward-char).This is equivalent to the usual C-f Emacs binding. The point will be just after the paren: (|do-bar).
  • Press SPC (vilpy-space) for inserting a whitespace character and type with-foo.
  • Use backtab (vilpy-special) for getting back to special mode. The point will be just before the paren, like this: |(with-foo do-bar).

Remove (b) and (c) from do-baz

  • Press j for getting to do-baz.
  • Use l twice for getting to (b).
  • Then, use C-k (vilpy-kill) for killing until the end of the parent sexp.

Copy (a) to the line below

  • Use backtab for getting back to special mode.
  • y for copying (a).
  • Press h (vilpy-step-out) for getting to the paren sexp.
  • Use backtab for switching to the matching paren and RET for opening a new line. This is equivalent to just using o (vilpy-open-line-below).
  • Finally, press C-y (the standard yank command) for pasting the previously copied sexp.