Questions tagged [custom-text-object]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
16 views

How to remap default vim text-object keys to different keys like ' to n

I use ci', va" pretty often, I would like to map text-object keys like " ' to more accessible keys like m, n since writing cin, vam is much easier than ci' va". I tried the following ...
2 votes
2 answers
102 views

Copy content inside brackets and the word in front of bracket (i.e. a text object for function calls)

Quite often I copy or remove content inside brackets d% or y%. MyAwesomeClass( ///content ) But this way I get: ( ///content ) Is there a way to copy word in front of the bracket too? So that ...
  • 139
1 vote
3 answers
258 views

How to copy between two '##'

In vim, there is a way to yank between two quotations by using yi'. And there is a way to yank between two square brackets by using yi]. I want to do this between two ##: some_text ## Point #1 --> ...
0 votes
0 answers
12 views

How can I sync part of a DOC cross reference with another file?

Is there a way in Vim to sync part of the markdown DOC across multiple files? For example, I have a description of a project, and I have to insert it in other files. When the main description is ...
3 votes
1 answer
37 views

Text Object for HTML/XML attributes, e.g. data-foo="bar baz caz"

Is there a plugin or a way to work with HTML text objects, e.g. Say the cursor is in one of the attributes below: <div data-foo="bar baz caz" class="a b c"> I wish to treat ...
2 votes
2 answers
62 views

Create a new matching-tag-pair textobject?

Vim provides a builtin textobject t that captures a matched pair of HTML tags — so e.g. if you start with this <i>that█ <b>those</b></i>, then typing dat in normal mode leaves ...
1 vote
1 answer
65 views

How to handle no content for a custom text object?

I am building custom text object in lua. With the following code, I am able to change content within certain symbols. This is my code: local in_symbol = function(start_symbol, end_symbol, mode) ...
0 votes
1 answer
112 views

An easier (or friendlier) way to write text object

Text objects are one of the power of Vim that I particulary like. I wanted to create my personnal text object with the p (="previous") and n (="next") parameters. For instance if I ...
1 vote
2 answers
89 views

Text object for a field between tabs

I'd like to define a text object for tab-delimited fields in a tsv file. So far, I have vnoremap af :<C-U>silent! normal! T<Tab>vf<Tab><CR> omap af :normal Vat<CR> ...
  • 111
2 votes
1 answer
37 views

Is a smart text object possible?

Is it possible to create a smart text object for i), i], i}, i>, i' and i"? The text object would represent the first innermost object it can find. For example, with cursor on the plus sign ...
3 votes
1 answer
113 views

Disabling `kana/vim-textobj-entire` by filetype autocommand

kana/vim-textobj-entire creates text-obejcts ae and ie which stand for the entire buffer. But in lervag/vimtex ae and ie stand for an environment in a .tex file. vimtex's ae and ie mappings are much ...
  • 532
1 vote
3 answers
239 views

Selector for line of text?

To grab a full word from anywhere in the word I can do: viw And to grab an entire line from start to finish I can do: V However, is there a section that grabs all text from the first char to the ...
  • 1,887
2 votes
2 answers
378 views

Is there an instant way of editing matching inner tags?

In Vim, using the text object i>, you can edit an inner tag, and using the built-in matchit plugin, you can even use % to jump between matching opening and closing tags. Let's say you want to ...
  • 43
1 vote
2 answers
75 views

Inserting text at the beginning of all lines selected in visual line mode [duplicate]

I have selected a JS block such as following: function map(xs: string[], cb: Function) : string[] { const result: string[] = []; for(let i = 0; i++; i < xs.length) { result.push(cb(xs[i]));...
  • 145
5 votes
3 answers
862 views

Is there a way to "move to the beginning of the next text object"?

Suppose I have a defined text object. For example, I have a ii text block which defines all the contiguous lines around the cursor at the same level of indentation or deeper. I know what it means to, ...
1 vote
1 answer
103 views

Custom prompt message when saving file

The default message displayed on the prompt when one saves a file is "<file_name>" <nlines>L, <ncharacters>C written and it remains in the prompt until another message is to be ...
  • 159
1 vote
1 answer
45 views

Change definition of "under the cursor" for ctags with C++ qualifiers

When jumping to a tag it seems that ":" are ignored for the purpose of "under the cursor" (I'm assuming it's "word" "under the cursor"). For example if I want to jump to myTree::Node something I ...
  • 163
3 votes
2 answers
172 views

How to remap ci$

I am using the plugin vimtex. It offers the functionality (from the introduction of its documentation) Text objects ic ac Commands id ad Delimiters ie ae LaTeX environments i$ a$ ...
's user avatar
6 votes
1 answer
230 views

How to pass v:register to custom operator when working on custom text object?

I have a simple custom operator, it echoes v:register, it's mapped to ,f. After reading this, i creat it like this : function! s:foo(type,...) echo v:register endfunction function! s:setupOpfunc(...
  • 5,978
1 vote
3 answers
394 views

Selecting code chunk in Rmarkdown

I am writing an RMarkdown file, which is a document that is a hybrid of text and R code. Here is an example of what that document could look like: Here is an example of text within my Rmarkdown file. ...
  • 13
7 votes
2 answers
1k views

How can I tell vim to ignore spelling errors inside quotes?

If I'm editing a text file with :set spell, is there any way to have vim not check words within the boundaries of certain characters against the word list? I want to be able to write things like ...
0 votes
2 answers
43 views

define a text object as the boundary of two marks

Is there a way to turn the "region bounded by two specific marks" into a text object similar to aw or ap? I've been messing around with vi and found it convenient to use a and b. and define a region ...
  • 1,663
2 votes
0 answers
38 views

Do operator ranges/movements/textobjects always overwrite the last visual selection? workaround?

In vim, when I operate on a textobject from a plugin, say the 'inner indent' typed ii from kana/vim-textobj-indent, my last visual selection ('>, '<) is reset to where the operator worked on. ...
  • 113
11 votes
1 answer
1k views

How to visually select based on indentation?

If someone is editing the following javascript file: let foo = true if (foo) { let bar = 42 // moooooore code... } You can use vi{ anywhere on the line with let bar to select let bar = 42 and ...
  • 253
0 votes
1 answer
81 views

How can I create a text object for a Python block comment?

Suppose I have some Python code with a “block comment” (i.e. multiple consecutive comment lines) in the middle of a paragraph: a = function1() # Remember: if you pass an even number to function2, ...
  • 2,573
1 vote
0 answers
184 views

Define new text object for snake case

I recently discovered iskeyword as in set iskeyword-=_ so that I can change just part of a snake case word, like changing character_idx to char_idx using ciw. This was working great, except sometimes ...
  • 475
2 votes
1 answer
69 views

Is there a text object or motion for non-comment lines are not separated from comment lines by blank lines? E.g., in git commit messages

Consider the text A B # C # D Is there a text object or motion that will select lines A and B if the cursor is on either, but not select lines C and D? ap or ip with the cursor on any of those four ...
  • 914
6 votes
2 answers
745 views

Change text between two $ symbols

If there is some text between quotations, such as "x = 5" I can type ci" in normal mode to delete the text inside the quotations and switch to insert mode. I often want to perform this same action ...
2 votes
1 answer
63 views

change inner backslashed quotes

I know the ci" motion and others :changes, but I need something like a ci\" in order to change inner a backslashed quotes. Assuming * as the cursor position: a = "message says: \"fo*o bar\"" I would ...
2 votes
4 answers
672 views

How to select/delete/yank the contents of only the current fold?

When using foldmethod=marker, how do you select or reference exactly the contents of the current fold? I want to swap the order of two folds. If they were paragraphs, I would do dap { p. However, I ...
  • 914
2 votes
0 answers
115 views

New text object for LaTeX subscript or superscript

Suppose in a latex file, I have a line $X_{i_{j}}$ and $Y^{i_{k}}$ My goal is to define a text object in VIM for the subscript, i.e. _{i_{j}}, and superscript, i.e. ^{i_{k}}. I was reading this ...
  • 121
1 vote
0 answers
73 views

Vim operation - creating a new text object selector for entire file [duplicate]

You can do dap, or vap, etc to select a paragraph. I want to be able to select/yank/delete the entire file. One way to do this would be to have: vnoremap af ggoG$ nnoremap yaf ggVGy nnoremap daf ...
0 votes
1 answer
73 views

How can you turn off text highlighting (hlsearch) with custom text objects?

I am implementing a custom text object in visual mode, but this text object uses regular expressions to find the beginning and ending of the selection. However, when I do this, other parts of the text ...
  • 427
3 votes
1 answer
1k views

Using Text Objects with vimtex

I am having trouble figuring out how to use the text objects with the vimtex plugin. The mappings with leaders and the commands in normal and insert mode are fine. But to get environments, sections, ...
  • 131
4 votes
1 answer
146 views

textobj-user: must the patterns be different?

I'm trying to make a text-object that is a paragraph surrounded by lines containing %. To test something simpler, I tried: call textobj#user#plugin('pc', { \ 'code': { \ 'pattern': ['%<', '%'...
  • 3,059
8 votes
1 answer
83 views

Define text object that depends on the current operator

I'm curious if it is possible to make a text object aware of its operator. In particular, I am writing a text object for LaTeX environments, where I want different behaviour depending on the operator. ...
13 votes
2 answers
3k views

Is there a text object for current line?

Is there a text object for current line? Is there a text object for ^$?
  • 427
11 votes
2 answers
225 views

Rectangular regions as text objects?

Is it possible to define a text object in vim that will act on a rectangular region? For instance, suppose I have vertically aligned columns of text, like this: column 1 co column 2 col lumn 1 ...
34 votes
5 answers
2k views

Is there a text object for the entire buffer?

I often find myself typing commands like gg"+yG or ggdG and would like a more efficient way to do this without having to move the cursor twice. Is there any command that I can use e.g. y[movement] to ...
  • 1,172
31 votes
5 answers
576 views

How can I treat LaTeX quotes as a text object?

Quotation marks in LaTeX are different than in normal text, in that they're formatted ``like this'' (or `like this' for single quotes). This makes it difficult to navigate through them in Vim. I ...
  • 13.9k