guns / vim-sexp

Precision Editing for S-expressions
MIT License
612 stars 33 forks source link
             o8o
             '"'
 oooo    ooooooo ooo. .oo.  .oo.        .oooo.o  .ooooo. oooo    ooooo.ooooo.
  `88.  .8' `888 `888P"Y88bP"Y88b      d88(  "8 d88' `88b `88b..8P'  888' `88b
   `88..8'   888  888   888   888 8888 `"Y88b.  888ooo888   Y888'    888   888
    `888'    888  888   888   888      o.  )88b 888    .o .o8"'88b   888   888
     `8'    o888oo888o o888o o888o     8""888P' `Y8bod8P'o88'   888o 888bod8P'
                                                                     888
                                                                    o888o

Introduction

Vim-sexp brings the Vim philosophy of precision editing to S-expressions.

Requirements

Definitions

A COMPOUND FORM is a region of text delimited by a pair of ( and ), [ and ], or { and }.

A STRING is a contiguous region of text whose syntax name matches the Vim pattern \vstring|regex|pattern.

A COMMENT is a region of text whose syntax name matches the Vim pattern comment. Line comments that are indented but on successive lines are considered to be a single comment.

MACRO CHARACTERS are the special set of leading characters expanded by a Lisp reader at read-time. These differ by language, and default to Scheme's macro character set in an unknown FileType.

An ELEMENT is the

An ELEMENT always includes any leading MACRO CHARACTERS.

Mappings

All default mappings can be changed via the g:sexp_mappings variable. Every mapping is available as a <Plug> mapping, which may be used for any purpose.

Users who desire more explicit, opt-in configuration should refer to :help sexp-explicit-mappings.

Comprehensive documentation is available at :help vim-sexp. The following is a brief summary.

Text Object Selections (visual, operator-pending)

Text object selections refer to text around the cursor.

Text Object Motions (normal, visual, operator-pending)

Text object motions move the cursor in normal mode, extend selections in visual mode, and refer to text defined by the movement of the cursor in operator-pending mode.

Indent Commands (normal)

Wrap Commands (normal, visual)

Wrap commands wrap the current COMPOUND FORM, ELEMENT, or visual selection and place the cursor at the head or tail of the newly created COMPOUND FORM.

If g:sexp_insert_after_wrap is set (true by default), insert mode is entered after wrapping.

List Manipulation (normal, visual)

List manipulation commands change the structure of COMPOUND FORMS. If these commands are called from visual mode, the selection is used in place of the current COMPOUND FORM or ELEMENT.

The last two commands are also known as barfage and slurpage in paredit.el.

Cursor Insertion (normal)

If inserting at the head, a space is conditionally appended after the opening bracket so that any typed characters will be separated from the next element.

Insert Mode Mappings (insert)

Vim-sexp does intelligent bracket and double quote insertion like paredit.el. Unlike ParEdit, deletion of brackets that would cause an imbalance is not prevented, except in the limited case of <BS> below.

These insert mode mappings can be disabled with:

let g:sexp_enable_insert_mode_mappings = 0