Questions tagged [object-motions]

Question about text object motions

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

text object for highlighted text

If I have a file that contains this_is_the_first_underscore_phrase this_is_the_first_underscore_phrase I search for "first" /first and my cursor is placed onto the start of the word "first". I know ...
1
vote
2answers
52 views

visual line mode is ended by inner block motion

When I do Vi{y to select inside a { block and yank it, it doesn't paste how I expect. I noticed that after V (which puts me into VISUAL-LINE mode), the i{ object takes me into VISUAL mode. Here's a ...
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
1answer
47 views

Automatically jump to text object during `ci(`

Suppose my cursor is at the beginning of the line of code: def f(a, b, c, d, e): If I want to change inside the parenthesis using the text object command ci(, I need to first navigate to some ...
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 ...
6
votes
4answers
132 views

How can I delimit sentences by carriage return?

I write screenplays with fountain. Dialogue syntax looks like this: THE TERMINATOR Hasta la vista. Baby. I would like to be able to select the sentence: Hasta la vista., without also selecting THE ...
1
vote
2answers
46 views

Changing content within the specified [count] number of braces for each line

I need to change the content within a [count] number of braces for each line in my buffer. 1 {Lorem} ipsum dolor {amet} blah blah {change this text} more blah blah 2 Hello. The {sun} rises in {the} ...
0
votes
2answers
44 views

Extract JavaScript variable (feature example): how to improve it?

I am a Vim newbie with one week experience and I'm already enjoying it. I've successfully written an (ugly) command+function+mapping with which I can extract some code to a new variable in JavaScript....
1
vote
2answers
171 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 ...
1
vote
1answer
46 views

How do I move by paragraphs, but end up *in* the paragraph?

So I often use repeated invocations of gqip to re-wrap paragraphs of text or comments. Unfortunately, the quickest way I've memorized for moving between paragraphs, }, lands me between them: Qui⁁ut ...
6
votes
2answers
284 views

How can I shift only inner contents of HTML element?

How can I quickly shift only inner contents of HTML tag X, when they are on separate lines to the opening and closing X tag? Example below: I want to shift only 2 lines with <p> tags when the ...
2
votes
1answer
197 views

Remap standard motions

I have a file formatted like this +---------------------------------+ | Text text text | | Text text text | | Text text text | +---------------------...
1
vote
1answer
69 views

onoremap: defining a bounded region

I want to craft a custom operator-pending motion if for functions in R language that look like this: doSomething <- function(arg1, arg2, ...) { doStuff(...) } The idea is to be able to press ...
6
votes
2answers
419 views

Why does dt$ not delete until the end of line?

I understand that the right way to delete until the end of line is d$, but why does dt$ not work also?
1
vote
1answer
62 views

Act on lines changed by previous command

Is there a way to target the set of lines changed in the previous command? Say I do a search and replace, bulk indent, or some other command that affects either a series or scattered collection of ...
1
vote
0answers
51 views

Vim Text object and parentheses [duplicate]

I have a trouble with text objects and parentheses. For example with this sentence: <bla bla="test">(hello)</bla> With the cursor at the beginning of the line, when I use ci" ("change ...
3
votes
1answer
79 views

Word motion and dots behaves differently in bash scripts

If I have a test.py and a word with dots, w motion goes through each "subword". If I have a test.sh and the same word with dots, w skips the dots. How do I debug this to know what is causing this ...
3
votes
1answer
124 views

Abort an operating pending mapping

When creating an operator pending mapping in vim, it is possible make the mapping work on an arbitrary (consecutive) piece of text. I am looking for a way to abort the operation. For the case of ...
4
votes
3answers
395 views

Why does replace not accept a motion?

A lot of operator like delete, change, indent, switch-case accept a motion to apply on. For example, let say I want to replace the current word with all letter a, I do: viwra Compared to the ...
1
vote
0answers
81 views

How to customize object-motions?

Text object motions are useful to move around in a file. Although these motion commands were specifically created for text (novel) writers, they can also be used in C source code. The commands gd and ...