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
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 ...
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. ...
20
votes
2answers
353 views

Why does "Operator" + "Motion" behave inconsistently?

This is something that has bugged me for a long time, but I've never gotten around to asking about. Say the text in your buffer looks like this: Hello World If I put my cursor somewhere in line 2, ...
2
votes
2answers
621 views

Move to the first/last non-whitespace character of the column ("vertical W/B/E")

For instance move from (the cursor is on the letter in bold italic, in the second column) blablabla blablabla blablabla blablabla bla bla bla bLablabla l@st to blablabla blablabla blablabla ...
2
votes
2answers
276 views

Repeat complicated motions

I know that similar things were asked here several times. I know that to repeat a motion ; works. Unless it doesn't(in case there is count for example), but then repmo.vim usually works. And I know ...
17
votes
2answers
2k views

Expand f and t motion to next lines

Is there a way that t{char} and f{char} will continue to work in the next lines if {char} is not present in a given line? I would like to avoid using /{char}<CR> to save 1 keystroke and to not ...
38
votes
5answers
23k views

How to disable arrow keys in vim?

I want to teach myself to prefer hjkl more over the arrow keys in order to stay on the home row. (I am very aware that one should not use hjkl as the main navigation keys as there are more powerful ...
6
votes
2answers
2k views

How to delete entire function definition (C style)

How can I delete the block int Test() { // } when my cursor is before int (or even better when it is anywhere on that line)? The shortest I could come up with is d<line>G where <line> ...
6
votes
2answers
4k views

Jumping to start/end of function definition in C++

Is there an easy way to jump to the beginning or end of the function your cursor is currently inside? It doesn't seem like sentence/paragraph/section have useful syntax aware meanings when editing C++....
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 ...
20
votes
1answer
4k views

End of python block motion

I need a motion that moves to end/beginning of a python block, and I need another motion that moves to begining/end of previous/next method/class (all combinations). I've tried vim-indent-object, ...
21
votes
2answers
6k views

Why do `cw` and `ce` do the same thing?

This has always bugged me about the w and W motion commands—they seem to work differently when used with the change command than they do when used alone, or with the delete command. For example, with ...
9
votes
2answers
205 views

Make sense of "[[", "]]", "[]", "]["

I found it hard to understand these text object motions: *]]* ]] [count] sections forward or to the next '{' in the first column. When used after an ...
4
votes
3answers
557 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
2answers
80 views

How to change f{char} to search left if no char was found searching right?

Regarding this command: f{char} To [count]'th occurrence of {char} to the right. The cursor is placed on {char} |inclusive|. {char} ...
65
votes
3answers
20k views

Why does vim use hjkl for cursor keys?

Why use the keys hjkl on the same line instead of keys in a triangle like wasd for moving on video games? Why not something equivalent with right hand, like ijkl or pl;'?
31
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 ...
16
votes
3answers
2k views

Mapping with motion

I'm trying to understand how can I use operator with subsequent motion inside a mapping. For example: nmap /c c{here we pending for a motion}/<C-r>"<CR> The map should do the following: ...
30
votes
4answers
515 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
783 views

Change the cursor shape in operator pending mode

My cursor in Gvim: My cursor in Gvim after pressing d: Is there any way I can change the cursor in terminal Vim when in operator pending mode? It doesn't have to look exactly like the screenshots. ...
10
votes
3answers
2k views

How to delete till the end of the previous line?

An example (The ^ is the cursor position): Before: a bc def ghi j k l mn o p q rs ^ After: a bc def ghimn o p q rs ^ or at least: a bc def ghimn o p q rs ^ I know I ...
9
votes
3answers
975 views

Jump to next identifier in Vim help files

I regularly find myself in the situation that I am reading a help topic and see an identifier (the blue underlined words) that I want to follow with <C-]>. However, most of the time the ...
13
votes
2answers
2k 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
3answers
847 views

How can I use marks to jump to locations in files I have recently opened, but not changed?

Often times I edit a file - think my work is done - then close the file and move on to the next thing. But then I realise I need to go back to that code and tweak it a bit more. If I open the file ...
8
votes
2answers
358 views

How do I surround a quoted string without including leading whitespace?

I have a string like 'foobar', and I want to surround it with parentheses: ('foobar'). With vim-surround, I can do ysi'), which produces '(foobar)'... Not what I want I can also ysa'), but that will ...
5
votes
1answer
175 views

Text formatting CVS-friendly

I have seen this very interesting article: http://dustycloud.org/blog/vcs-friendly-patchable-document-line-wrapping/ --- basically it is a suggestion for hard-breaking lines of text (for example, in ...
4
votes
1answer
2k views

Change/delete matching brackets at the same time

Sometimes I write something in brackets and then realize I've typed the wrong kind. For instance, in LaTeX: \command(arguments) Which should be: \command{arguments} I can jump between the two ...
3
votes
0answers
158 views

how to delete a paragraph respecting the folds?

I have a file (filetype=javascript), this is how it looks without folds: and with folds: I can move with the { and } motions skipping the empty lines inside the folds (thanks to these question and ...
12
votes
1answer
822 views

Why does >3k move the cursor up when >3j does not move it down? [duplicate]

Hitting >3j indents the current line and the three below it, and >3k does the same but with the three lines above. However, when indenting down, my cursor is left on the same line as it started, ...
4
votes
1answer
229 views

Modify `iskeyword` for keyword-local completion only

Context Some time ago, I added the following line to ~/.vim/after/ftplugin/sh.vim to make working with parameter expansions easier: setlocal iskeyword+=$ This is nice to be able to e.g. ysiw" via ...
4
votes
3answers
335 views

Reverse a set of paragraphs

Is there a good way to reverse a set of paragraphs (navigable via cursor motion { and })? My practical use case is reversing the order of blocks of latex code (ie, reversing the order of jobs in a ...
3
votes
1answer
204 views

How do I get the text that is chosen by some motion?

I'm wanting to write a simple plugin that allows using a motion to choose some text and then processes that text. I'm trying to find out how to get the text that a motion results in. So far I haven't ...
3
votes
1answer
140 views

Unable to set iskeyword for colon ( : ) character

I am using vim to edit LaTeX files. Throughout the text, there are labels to equations, tables etc. for which an accepted convention among TeX writers is the following \label{eq:massenergy} , \...
3
votes
1answer
89 views

How to search in visual mapping?

I am trying to create a text object for consecutive lower-case letters. Here is how I am setting up the inner text object: xnoremap in :<C-u>normal! ?[^a-z]?e+1<CR>v/[^a-z]/s-1<CR> ...
3
votes
3answers
3k views

Control - Arrow to Skip Over Text

I am new to Vim, however I am learning to love it. As a former/current Windows user, there is one shortcut that I depend on and would like to configure in Vim. On windows I can use ctrl-arrow left ...
3
votes
1answer
91 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 ...
2
votes
1answer
434 views

Motion key for next highlighted item?

Using the normal spell-check mechanism in vim one can jump from one misspelling to the next using ]s. Sadly vim's spell-check is completely useless for Turkish. Using the vimchant plugin that hooks ...
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 ...
1
vote
3answers
142 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 ...
0
votes
1answer
69 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 ...