From b6430c147a5cf8b557cb0a8dac117e2397b6c5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Wed, 7 Apr 2021 21:30:19 +0200 Subject: [PATCH] doc: more help on text objects --- doc/vimtex.txt | 87 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/doc/vimtex.txt b/doc/vimtex.txt index a9fad0a98c..a6e3901a34 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -44,6 +44,7 @@ CONTENTS *vimtex-contents* Map definitions |vimtex-mappings| Insert mode mappings |vimtex-imaps| Events |vimtex-events| + Text objects |vimtex-text-objects| Completion |vimtex-completion| Complete citations |vimtex-complete-cites| Complete labels |vimtex-complete-labels| @@ -70,7 +71,7 @@ CONTENTS *vimtex-contents* Syntax conceal |vimtex-syntax-conceal| Syntax group reference |vimtex-syntax-reference| Navigation |vimtex-navigation| - Include expression (|gf| command) |vimtex-includeexpr| + Include expression (gf command) |vimtex-includeexpr| Table of contents |vimtex-toc| Custom mappings |vimtex-toc-custom-maps| Denite/Unite source |vimtex-denite| / |vimtex-unite| @@ -3137,35 +3138,20 @@ MAP DEFINITIONS *vimtex-mappings* *(vimtex-delim-close)* Close the current environment or delimiter (insert mode). - -Note: The following describe text objects and motions. For the text objects, -the usual convention is used where the "a" select "a"n object, including the -whitespace/delimiters/etc, whereas the "i" selects the corresponding "inner" -object, see |text-objects|. - -*(vimtex-ac)* +*(vimtex-ac)* Commands *(vimtex-ic)* - Text object for commands. - -*(vimtex-ad)* +*(vimtex-ad)* Delimiters *(vimtex-id)* - Text object for delimiters. - -*(vimtex-ae)* +*(vimtex-ae)* Environments *(vimtex-ie)* - Text object for environments. - -*(vimtex-a$)* +*(vimtex-a$)* Inline math *(vimtex-i$)* - Text object for inline math. - -*(vimtex-aP)* +*(vimtex-aP)* Sections *(vimtex-iP)* - Text object for sections. - -*(vimtex-am)* +*(vimtex-am)* Items *(vimtex-im)* - Text object for items. + These are all text object mappings for the indicated types of objects , see + |vimtex-text-objects| for more info. *(vimtex-%)* Find matching pair. @@ -3471,6 +3457,59 @@ Examples: > au User VimtexEventTocActivated normal! zt augroup END +------------------------------------------------------------------------------ +TEXT OBJECTS *vimtex-text-objects* + +Text objects (and motions) are a fundamental feature in Vim. Operations can be +combined with motions or text objects in endless ways and can be repeated with +the dot operator (|repeat.txt|). If you are reading this and do not know about +these things, then it is strongly adviced to read the help section about +|text-objects| and the famous Stack Overflow post "Your problem with Vim is +that you don't grok vi": +http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118 + +VimTeX defines LaTeX specific text objects (and motions). These are all +mappings, and as such, they are also described in the sections +|vimtex-mappings| and |vimtex-default-mappings|. + +The usual convention for text object mappings is to prepend "a" to select "a"n +object, including the whitespace/delimiters/etc, and to prepend "i" to select +the corresponding "inner" object. This is the case for VimTeX text objects, +e.g. by default, `vie` will visually select the inner part of an environment, +whereas `vae` will select the entire environment including the boundaries. + +VimTeX supports the well known |targets.vim| as a "backend" for text objects. +This should work automatically, see |g:vimtex_text_obj_variant| for more info. + +Some examples of how to use the text objects can be useful. The following is +a simple table that shows the original text on the left, the keys that are +typed in the middle, and the result on the right. The bar "|" indicates the +cursor position before the operation. > + + BEFORE KEYS AFTER + \comm|and{arg} dic \command{} + \command{a|rg} gUac \COMMAND{ARG} + + \lef|t( asd \right) cid \left(| \right) + + \begin{x} die \begin{x} + hello world| \end{x} + \end{x} + + $math | here$ da$ + + \begin{itemize} \begin{itemize} + \item hello moon| cim \item | + \end{itemize} \end{itemize} + + \begin{itemize} \begin{itemize} + \item hello moon| dam \end{itemize} + \end{itemize} + +Associated settings: +* |g:vimtex_text_obj_enabled| +* |g:vimtex_text_obj_linewise_operators| +* |g:vimtex_text_obj_variant| ============================================================================== COMPLETION *vimtex-completion*