Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select inside dollar signs in Vim with Vim/LaTeX plugin

Is there a way to select inside dollar signs $...$ possibly using tools within the vim-latex suite? Ideally, it would be vi$ to match vi(, vi[, vi" which select the contents inside parentheses, brackets, and quotes, respectively.

A macro such

let @q='F$lvt$'

is undesirable since it isn't invoked by the obvious vi$.

Thank you.

like image 811
jmlarson Avatar asked Jan 27 '16 15:01

jmlarson


2 Answers

A possible answer is:

:onoremap <silent> i$ :<c-u>normal! T$vt$<cr>
:vnoremap i$ T$ot$

This make the following work:

  • di$, yi$, gUi$, or any command which expects a motion will now recognize i$ as a usable motion;
  • vi$ will select the expected range.
like image 104
yolenoyer Avatar answered Nov 02 '22 23:11

yolenoyer


You can create a custom text-object:

xnoremap i$ :<C-u>normal! T$vt$<CR>
onoremap i$ :normal vi$<CR>

which can be used intuitively with v, d, y, c:

di$
vi$
ci$
yi$
like image 36
romainl Avatar answered Nov 02 '22 23:11

romainl