0

Two questions related to the DelimitMate plugin here:

  1. How can I modify the set of auto-generated left and right delimiters? For example, in LaTeX it would be convenient to have $ as left-right delimiters, and if possible somehow, \[ and \] (even though this includes the brackets, which the plugin seems to detect independent of the escape).

  2. Is there any way to map some insert-mode keystroke to "move to the right" of the most recently generated right-delimeter? That would make editing certain types of files a lot easier. Something like inoremap <C-l> <move to end of automatically-generated delimiter>.

1
  1. Look into the delimitMate_quotes variable. The following line in your vimrc should take care of the $ sign delimiter.

    au FileType tex let b:delimitMate_quotes = "\" ' $"

Not sure how you would go about setting a delimiter for \[.

  1. Checkout some of the answers to this question.
  • Thanks! Do you know any way to modify unlike pairs as well? Weirdly, I found if I try to change &matchpairs with set matchpairs="(:),{:},[:],<:>", the plugin completely breaks/stops working. – Luke Davis Feb 24 '17 at 22:49
  • Yes. Use the delimitMate_matchpairs variable. The line you are looking for is let delimitMate_matchpairs = "(:),{:},[:],<:>". I thought that this variable could perhaps be used to set \[ as a delimiter as your question mentions, but it doesn't seem like it is able to accept a multi-character delimiter. See the delimitMate doc for more info on this variable. – Bryan Bugyi Feb 25 '17 at 1:47
  • I've edited my answer to try and address your second question as well. – Bryan Bugyi Feb 25 '17 at 2:11
0

For anyone reading this, I figured out that to move "outside" a set of (), [], or {} can be accomplished with

inoremap ;; <Esc>l%%a

where I choose to use a double-semicolon, because I find in day-to-day typing that I never use the semicolon unless followed by a space, and its in a really convenient location. Also, while you can't really make arbitrary, multiple-character delimiters work inside of DelimitMate, you can make simple remaps for adding them; an example is my series of maps for bolding text in TeX documents:

au FileType tex inoremap <buffer> ;t \textbf{}<Left>
au FileType tex nnoremap <buffer> ;t mAlbi\textbf{<Esc>ea}<Esc>`A
au FileType tex vnoremap <buffer> ;t mA<Esc>`>a}<Esc>`<i\textbf{<Esc>`AF\

which bolds the current word, current selection, or just adds a \textbf{} during insert mode and puts the cursor inside the curly braces. The <buffer> makes the above maps local to the file being edited, so they won't be carried over e.g. if you are working on a .py file in another tab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.