Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [custom-text-object]

The tag has no usage guidance.

4
votes
2answers
58 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
2answers
30 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 ...
2
votes
0answers
24 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. ...
4
votes
1answer
53 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 ...
0
votes
1answer
37 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, ...
1
vote
0answers
37 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 ...
3
votes
1answer
65 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 ...
6
votes
2answers
114 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
1answer
50 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 ...
1
vote
2answers
145 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 ...
2
votes
0answers
48 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 ...
1
vote
0answers
63 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
1answer
54 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 ...
1
vote
1answer
634 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, ...
4
votes
1answer
98 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': ['%<', '%'...
8
votes
1answer
62 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. ...
10
votes
1answer
400 views

Is there a text object for current line?

Is there a text object for current line? Is there a text object for ^$?
11
votes
2answers
151 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 ...
28
votes
4answers
919 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 ...
29
votes
4answers
364 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 ...