How to make a text object/motion with begining and ending pattern in Vim -



How to make a text object/motion with begining and ending pattern in Vim -

i define text object iw, ab , other ones listed in :help text-objects defines area origin pattern , ending another. more precisely, define text object starts {pattern1} , ends {pattern2}. patterns included. of import can stretch on multiple lines (like ab unlike a").

the examples have in mind selecting in-line equations in latex, is, between 1 $ , next $ (including $'s), , selecting latex environments between \begin{*} , next \end{*}, * here string of characters (but non-greedy \{-} in vim regex).

i have tried tried @ this guide @ vim tips wiki, not know how replace [z , ]z searches backwards pattern , forwards patters, respectively, works want to.

so give illustration of inline equation (lets text obejct called ad), then, if cursor placed somewhere between $'s in next line:

it follows $ \sum_{n=0}^\infty 2^{-n} $ 2

in normal mode, , vad pressed, $ \sum_{n=0}^\infty 2^{-n} $ should in visual, or if dad pressed should deleted.

the mentioned vim tips wiki page lists 2 plugins (under "related scripts") create defining new text objects easy:

textobj-user flexible , generic countjump plugin (by me) specially written text objects defined start , end patterns

the next phone call defines ad text object text within $...$:

call countjump#textobject#makewithcountsearch('', 'd', 'a', 'v', '\$', '\$')

vim

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -