insert_api.d.elv 4.0 KB

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