6

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.

jmlarson
  • 837
  • 8
  • 31

2 Answers2

8

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.
yolenoyer
  • 8,797
  • 2
  • 27
  • 61
  • 2
    That is even better than what I was looking for! It is also a nice template for declaring text-blocks within other characters. I have also added `:onoremap a$ :normal! F$vf$` and `:vnoremap a$ F$of$` so that `a$` behaves as expected. – jmlarson Jan 27 '16 at 16:39
  • Will somebody please explain the first line – dlmeetei Jan 27 '16 at 16:42
2

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$
romainl
  • 186,200
  • 21
  • 280
  • 313
  • The commands can be made to work with ```a``` (select around, including the $ characters) with ```xnoremap a$ :normal! F$vf$``` ```onoremap a$ :normal va$``` – jonthalpy Nov 14 '18 at 05:40