Questions tagged [cursor-motions]

Commands that moves the cursor. A motion command is used after an operator command to move over the text that is to be operated upon.

Filter by
Sorted by
Tagged with
3
votes
1answer
457 views

How to skip over indentation whitespace with horizontal motion?

I have a file that uses 4-space indentation. By default, when I move horizontally, Vim moves over those spaces one by one. How can I configure Vim so that it moves 4 spaces horizontally when moving ...
20
votes
3answers
13k views

Multiple cursors at desired location

I'm using vim-multiple-cursors plugin. I would like to put cursors exactly where I want. For example ([x] are the cursor positions): Lorem ipsum dolor sit amet[1], consectetur adipiscing elit, sed ...
8
votes
4answers
1k views

Grok Vim motions and simple edits

I'm returning to Vim after using Emacs for a few years. I'm trying to grok Vim by reading and watching tutorials, as well as actually using it daily. When editing text, I find the Emacs commands of ...
8
votes
1answer
124 views

change meaning of "paragraph" for TeX input?

I'm writing LaTeX code which has a lot of sections like this \begin{definition} blah blah blah ... ... \end{definition} In normal text, I'm very fond of gq] to rewrap everything nicely. Inside a ...
3
votes
1answer
2k views

Visual select single column from cursor to last line with text in column

There are already a lot of similar questions to this. Jump to last line, but stay in the same column How to go to the end of the file in vim while preserving the current column under the cursor? How ...
4
votes
3answers
2k views

navigate within nerdtree

I wonder how folks navigate efficiently with in a nerdtree window, for example if I'm in a folder like this: ├── m1.py ├── m1.pyc ├── m2.py ├── m2.py.bak ├── m2.pyc ├── main.py ├── matplotdemo.py ├── ...
4
votes
2answers
262 views

column-wise f, F, t, T

Sometimes, I need to delete until a character up or down the same column. Consider a file with the following content: abc def hij When cursor is on b, doing a column-wise dfi should remove ...
9
votes
1answer
3k views

Define word boundaries

I use, e.g., dw to delete a word based on word boundaries defined by changing character classes, so that this command applied on abc,def,ghi will result in ,def,ghi. (So far so good, and it worked for ...
11
votes
3answers
554 views

Is there a motion similar to a" that never includes leading whitespace?

I'm using the a" motion rather often in vim; e.g. using ca" while refactoring a piece of code to replace a hardcoded argument with a variable name. The problem with this approach is that a" includes ...
11
votes
2answers
210 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 ...
8
votes
3answers
2k views

How to simply remove braces

One of my friend told me that I can use the trick below to remove a pair of curly brackets. Put the cursor inside the curly bracket pair you want to remove. y i { to yank the text in braces , then v ...
3
votes
3answers
3k views

Run macro over a visual selection with line movements

I can find an answer to a similar problem here, however although I can get that example to function I can't get what I want to do to work. Here is the example text to be edited, a partial section of ...
2
votes
2answers
190 views

Using the % command on a line without a bracket

I like formating code this way: class A { } unlike another common way: class B { } The thing is, when using the % command to go to the enclosing bracket, which is very useful for copying/deleting ...
2
votes
1answer
128 views

What's the best way to arrange subwords navigation?

I want Vim to treat the following as separate words: FirstSecondThird firstSecondThird first_second_third first.second.third first-second-third first#second#third What is the best solution for this? ...
6
votes
2answers
181 views

Recognize bash variable as distinct word

Is there any way to make vim treat bash variables (anything prefixed with a $, really) as distinct words? For instance, with the following lines: "name $suffix.ext" "name$suffix.ext" with the ...
30
votes
1answer
17k views

How can I jump to the next "paragraph"?

Right now I'm working with some blocks of text that are over 1000 lines long. Is there a simple way to move to the beginning of the next paragraph? My workaround for now is searching for two ...
33
votes
5answers
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 ...
11
votes
4answers
3k views

How do I move to the last character in a sentence?

In normal mode ( and ) move to the previous or next first character in the sentence, respectively. How do I move to the very last character. If all of my sentences end with a period I can use )T. (...
30
votes
4answers
510 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 ...
9
votes
1answer
374 views

How can I easily get the length of a piece of text?

I sometimes want to check the length of a piece of text, for example in this example: str = 'Hello, world!' if len(str) == 13: print('Hello back to you!') I would like to know the length of the ...
6
votes
2answers
260 views

Working with English sentences

When I'm editing English text, I need to work with full sentences instead of lines of text in the file. Using the default Vim commands for this kind of text manipulation is very awkward, because I may ...
10
votes
4answers
295 views

Restricting operations to a section of code

There is many times in my day to day work life that I need to operate on a specific function, things like highlighting or searching for a variable, but I have never managed to limit the scope of the ...
30
votes
4answers
1k views

Why can ci" be outside of quoted area and ci( only works inside parentheses?

When using ci" the cursor does not have to reside in the double quoted area. |String somestring = "some text"; Assuming the pipe is the cursor position, ci" will make it jump to the quoted area. ...

1 2 3 4
5