mirror of
https://github.com/tpope/vim-surround.git
synced 2025-11-13 13:53:49 -05:00
Proof of concept substitutions in user replacements
This commit is contained in:
@@ -138,9 +138,11 @@ specify attributes here and they will be stripped from the closing tag.
|
||||
End your input by pressing <CR> or >. As an experimental feature, if <C-T>
|
||||
is used, the tags will appear on lines by themselves.
|
||||
|
||||
An experimental replacement of a LaTeX environment is provided on \ and l.
|
||||
A deprecated replacement of a LaTeX environment is provided on \ and l.
|
||||
The name of the environment and any arguments will be input from a prompt.
|
||||
The following shows the resulting environment from csp\tabular}{lc<CR>
|
||||
This will be removed once a more fully functional customization system is
|
||||
implemented. The following shows the resulting environment from
|
||||
csp\tabular}{lc<CR>
|
||||
>
|
||||
\begin{tabular}{lc}
|
||||
\end{tabular}
|
||||
@@ -164,6 +166,29 @@ replacements.
|
||||
let g:surround_45 = "<% \r %>"
|
||||
let g:surround_61 = "<%= \r %>"
|
||||
<
|
||||
Advanced, experimental, and subject to change: One can also prompt for
|
||||
replacement text. The syntax for this is to surround the replacement in pairs
|
||||
of low numbered controller characters. If this sounds confusing, that's
|
||||
because it is (but it makes the parsing easy). Consider the following example
|
||||
for a LaTeX environment on the "l" replacement.
|
||||
>
|
||||
let g:surround_108 = "\\begin{\1environment: \1}\r\\end{\1\1}"
|
||||
<
|
||||
When this replacement is used, the user is prompted with an "environment: "
|
||||
prompt for input. This input is inserted between each set of \1's.
|
||||
Additional inputs up to \7 can be used.
|
||||
|
||||
Furthermore, one can specify a regular expression substitution to apply.
|
||||
>
|
||||
let g:surround_108 = "\\begin{\1environment: \1}\r\\end{\1\r}.*\r\1}"
|
||||
<
|
||||
This will remove anything after the first } in the input when the text is
|
||||
placed within the \end{} slot. The first \r marks where the pattern begins,
|
||||
and the second where the replacement text begins.
|
||||
|
||||
Inputting text replacements is a proof of concept at this point. The ugly,
|
||||
unintuitive interface and the brevity of the documentation reflect this.
|
||||
|
||||
ISSUES *surround-issues*
|
||||
|
||||
Vim could potentially get confused when deleting/changing occurs at the very
|
||||
@@ -172,7 +197,8 @@ end of the line. Please report any repeatable instances of this.
|
||||
Do we need to use |inputsave()|/|inputrestore()| with the tag replacement?
|
||||
|
||||
Customization isn't very flexible. Need a system that allows for prompting,
|
||||
like with HTML tags and LaTeX environments.
|
||||
like with HTML tags and LaTeX environments. (There is an experimental
|
||||
interface for this now).
|
||||
|
||||
Indenting is handled haphazardly. Need to decide the most appropriate
|
||||
behavior and implement it. Right now one can do :let b:surround_indent = 1
|
||||
@@ -180,4 +206,5 @@ behavior and implement it. Right now one can do :let b:surround_indent = 1
|
||||
should this be the default?
|
||||
|
||||
It would be nice if |.| would work to repeat an operation.
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
||||
Reference in New Issue
Block a user