src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/edit/insert_api.d.elv (about)

     1  # A map from simple abbreviations to their expansions.
     2  #
     3  # An abbreviation is replaced by its expansion when it is typed in full
     4  # and consecutively, without being interrupted by the use of other editing
     5  # functionalities, such as cursor movements.
     6  #
     7  # If more than one abbreviations would match, the longest one is used.
     8  #
     9  # Examples:
    10  #
    11  # ```elvish
    12  # set edit:abbr['||'] = '| less'
    13  # set edit:abbr['>dn'] = '2>/dev/null'
    14  # ```
    15  #
    16  # With the definitions above, typing `||` anywhere expands to `| less`, and
    17  # typing `>dn` anywhere expands to `2>/dev/null`. However, typing a `|`, moving
    18  # the cursor left, and typing another `|` does **not** expand to `| less`,
    19  # since the abbreviation `||` was not typed consecutively.
    20  #
    21  # See also [`$edit:command-abbr`]() and [`$edit:small-word-abbr`]().
    22  var abbr
    23  
    24  # A map from command abbreviations to their expansions.
    25  #
    26  # A command abbreviation is replaced by its expansion when seen in the command
    27  # position followed by a [whitespace](language.html#whitespace). This is
    28  # similar to the Fish shell's
    29  # [abbreviations](https://fishshell.com/docs/current/cmds/abbr.html), but does
    30  # not trigger when executing a command with Enter -- you must type a space
    31  # first.
    32  #
    33  # Examples:
    34  #
    35  # ```elvish
    36  # set edit:command-abbr['l'] = 'less'
    37  # set edit:command-abbr['gc'] = 'git commit'
    38  # ```
    39  #
    40  # See also [`$edit:abbr`]() and [`$edit:small-word-abbr`]().
    41  var command-abbr
    42  
    43  # A map from small-word abbreviations to their expansions.
    44  #
    45  # A small-word abbreviation is replaced by its expansion after it is typed in
    46  # full and consecutively, and followed by another character (the *trigger*
    47  # character). Furthermore, the expansion requires the following conditions to
    48  # be satisfied:
    49  #
    50  # -   The end of the abbreviation must be adjacent to a small-word boundary,
    51  #     i.e. the last character of the abbreviation and the trigger character
    52  #     must be from two different small-word categories.
    53  #
    54  # -   The start of the abbreviation must also be adjacent to a small-word
    55  #     boundary, unless it appears at the beginning of the code buffer.
    56  #
    57  # -   The cursor must be at the end of the buffer.
    58  #
    59  # If more than one abbreviations would match, the longest one is used. See the description of
    60  # [small words](#word-types) for more information.
    61  #
    62  # As an example, with the following configuration:
    63  #
    64  # ```elvish
    65  # set edit:small-word-abbr['gcm'] = 'git checkout master'
    66  # ```
    67  #
    68  # In the following scenarios, the `gcm` abbreviation is expanded:
    69  #
    70  # -   With an empty buffer, typing `gcm` and a space or semicolon;
    71  #
    72  # -   When the buffer ends with a space, typing `gcm` and a space or semicolon.
    73  #
    74  # The space or semicolon after `gcm` is preserved in both cases.
    75  #
    76  # In the following scenarios, the `gcm` abbreviation is **not** expanded:
    77  #
    78  # -   With an empty buffer, typing `Xgcm` and a space or semicolon (start of
    79  #     abbreviation is not adjacent to a small-word boundary);
    80  #
    81  # -   When the buffer ends with `X`, typing `gcm` and a space or semicolon (end
    82  #     of abbreviation is not adjacent to a small-word boundary);
    83  #
    84  # -   When the buffer is non-empty, move the cursor to the beginning, and typing
    85  #     `gcm` and a space (cursor not at the end of the buffer).
    86  #
    87  # This example shows the case where the abbreviation consists of a single small
    88  # word of alphanumerical characters, but that doesn't have to be the case. For
    89  # example, with the following configuration:
    90  #
    91  # ```elvish
    92  # set edit:small-word-abbr['>dn'] = ' 2>/dev/null'
    93  # ```
    94  #
    95  # The abbreviation `>dn` starts with a punctuation character, and ends with an
    96  # alphanumerical character. This means that it is expanded when it borders
    97  # a whitespace or alphanumerical character to the left, and a whitespace or
    98  # punctuation to the right; for example, typing `ls>dn;` will expand it.
    99  #
   100  # Some extra examples of small-word abbreviations:
   101  #
   102  # ```elvish
   103  # set edit:small-word-abbr['gcp'] = 'git cherry-pick -x'
   104  # set edit:small-word-abbr['ll'] = 'ls -ltr'
   105  # ```
   106  #
   107  # If both a [simple abbreviation](#$edit:abbr) and a small-word abbreviation can
   108  # be expanded, the simple abbreviation has priority.
   109  #
   110  # See also [`$edit:abbr`]() [`$edit:command-abbr`]().
   111  var small-word-abbr
   112  
   113  # Toggles the value of [$edit:insert:quote-paste].
   114  fn toggle-quote-paste { }
   115  
   116  # Binding map for the insert mode.
   117  #
   118  # The key bound to [`edit:apply-autofix`]() will be shown when an
   119  # [autofix](#autofix) is available.
   120  var insert:binding
   121  
   122  # A boolean used to control whether text pasted using
   123  # [bracketed paste](https://en.wikipedia.org/wiki/Bracketed-paste)
   124  # in the terminal should be quoted as a string. Defaults to `$false`.
   125  var insert:quote-paste