Questions tagged [custom-text-object]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4
votes
1answer
53 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(...
1
vote
3answers
76 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. ...
4
votes
2answers
74 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
32 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
26 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
64 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
41 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
45 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 ...
2
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 ...
5
votes
2answers
121 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
51 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
170 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
50 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
55 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
670 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
101 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. ...
9
votes
1answer
421 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
153 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
937 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
369 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 ...