Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

Filter by
Sorted by
Tagged with
104
votes
2answers
7k views

How do I navigate to topics in Vim's documentation?

In Vim's built-in help system, how do I… search for topics that I want help on? follow hyperlinks? browse around for related material?
29
votes
3answers
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. ...
23
votes
4answers
4k views

How do I deal with very long lines in text (500+ characters)?

For some text formats, line breaks matter. For example, I often use Vim to write MediaWiki documents, where you can't just put a linebreak anywhere (unlike Markdown). So I'm forced to write lines ...
30
votes
8answers
2k views

How do I move vertically until reaching a non-whitespace character?

In a very long file with (accurately-) indented code, it may be helpful to move directly to a line of text above or below the cursor which delimits the indenting. (One way of doing this could be via ...
21
votes
1answer
2k views

How to make movements respect camelCase or snake_case?

It is common to use either camelCase or snake_case to separate multiple words which form an identifier. It would be nice if the "word" movements (b, w, e) would detect those inner-identifier ...
11
votes
2answers
475 views

Scrolling issues when the `wrap` option is set

I find myself dealing with this issue every time the wrap option is active (in my particular case whenever I'm working with markdown files). What happens is that, while scrolling up and down the ...
19
votes
3answers
923 views

How can I get ‘n’ to go forward even if I started searching with ‘?’ or ‘#’?

Vim has (at least) two sets of commands that search in opposite directions. Typing / and then a pattern will search forward through the document for the pattern; typing ? and then a pattern will ...
0
votes
1answer
459 views

Quickest navigation within a buffer [closed]

Okay, here's the thing: let's say you have a buffer, 1000 lines long (a source code for example). And you want a super-fast navigation, jumping to the right place. Example: You are on a line 42, on ...
2
votes
2answers
370 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 ...
12
votes
4answers
3k views

Vim HardMode Fine Grain Movements

I recently found out about Vim hard mode and I've decided to try and use it. However, I'm running into some problems with fine grain movements. For example, let's say I really just want to move up or ...
29
votes
4answers
16k views

How to disable arrow keys in vim?

I want to teach myself using hjkl more than using 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 ...
86
votes
6answers
16k views

How do I jump to the location of my last edit?

I often make changes to the middle of a big file, use gg to jump to the top to check something, and then realize I forgot to set a mark where I was editing. Is there a built-in way to jump to the ...
5
votes
1answer
291 views

How can I advance a page without losing my column position?

I like using Ctrl-f and Ctrl-b to "page-up" and "page-down", but I was wondering if there was a way to do that without losing my current position in a row? For example, I like to work with tab-...
4
votes
1answer
854 views

How to make a movement function work with delete, yank, etc

In hope of answering Using the % command on a line without a bracket I tried to write my first Vim script. My thought was to check if there was a { on the current line. If there was one I wanted % ...
5
votes
4answers
295 views

Move vertically to a specific character on a different line

It is easy to move to a specific character on the same line with t or f. However often it is useful to move to the specific character that is positioned on a different line. Consider this example: ...
3
votes
2answers
172 views

Replace text and move cursor to end of replacement in insert mode

How can I perform a search-and-replace and leave the cursor at the end of the replacement? I want to replace $...$ with \(...\) as I type in insert mode. Notice that I can't use an abbreviation, ...
51
votes
3answers
13k views

How to jump between matching HTML/XML tags?

How to jump between matching tags (such as <div>, <span>, etc.) when editing HTML/XHTML/XML documents similarly as % is used to jump between matching parentheses?
26
votes
1answer
12k 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 ...
38
votes
6answers
5k views

Can I delete an entire line, except the line break?

A fairly common operation for me in vim, since I am compulsive-obsessive and like to keep my files free of whitespace, is to delete the contents of an entire line, but not the line itself (i.e. not ...
18
votes
2answers
969 views

Using % in languages without curly braces

In C and C-like languages, I can use % to jump to the corresponding curly brace that the cursor is on. This is a well-known "trick". But in Ruby for example: def fun [1, 2].each do |n| end ...
16
votes
2answers
5k views

How do I make Vim always display several lines after EOF?

In Vim, I don't like how when you reach end of file it puts the last line at the bottom of the screen. Is there anyway to make the last line be something like 10 lines above the bottom of the screen ...
13
votes
1answer
9k views

Jumping to a byte offset, and displaying position as byte offset

How can I move the cursor to the nth byte in the buffer? How can I display the current cursor position in the ruler in terms of the byte offset, rather than lines and columns? (Follow-up question: ...
8
votes
1answer
2k views

How do I get back to the previous line after moving?

I am new to Vim. My code file has 300 lines. Suppose currently the cursor is on line 254, and I used gg command the cursor turn to line 1. I want to go back to line 254 but I forget that line number. ...
6
votes
2answers
737 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 ...
16
votes
4answers
5k views

Scroll a quarter (25%) of the screen up or down

I often find scrolling a full page too disorienting, half a page too much, but a quarter page is just right. I currently do it just by holding down the arrow keys. How do I scroll 25% of the page ...
9
votes
2answers
1k views

Using marks with dead keys

I am using a keyboard layout in which the backtick (`) is a dead key. This means that when I type a backtick followed by a vowel (for example `a) what Vim sees is an accented character (à). So if I ...
8
votes
3answers
1k 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 ...
7
votes
1answer
750 views

What do matchit.vim's [%, ]%, a% do?

matchit's %/g% are simple enough to use, but I'm having trouble understanding the other mappings, which sound potentially useful but don't seem to work in any understandable way. ]% Go to [count] ...
7
votes
1answer
150 views

Why is the previously inserted text reset after using an arrow key?

From help :help i_ctrl-a: CTRL-A Insert previously inserted text. {not in Vi} Let's say I have an empty buffer and I'm in normal mode. I type i to go in insert mode. I type (), then move the ...
20
votes
2answers
608 views

How can I use a line number to copy a line to where my cursor is?

A lot of times I'm in a situation similar to this: 1. <Line 1> 2. <Line 2> 3. <Line 3> 4. <Cursor is here> 5. <I want to copy line 1 here> An easy solution is mm:1<...
15
votes
2answers
4k views

How to restore the position of the cursor after executing a normal command?

I am trying to code a function that replaces the character in the sixth column of my current line with a dollar symbol ($), but I would like my cursor to remain at the position it was before calling ...
12
votes
1answer
817 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, ...
6
votes
1answer
196 views

How to move the cursor to the next reference, option, heading in man pages?

If we load the built-in man.vim filetype plugin by writing in our vimrc: runtime ftplugin/man.vim We can read a man page inside a Vim buffer, using the :Man command described in :h :Man: MAN ...
5
votes
2answers
877 views

Keep cursor from moving when yanking upwards

I frequently find myself wanting to make a copy of, eg, a function that I just wrote and modify it slightly. In such a situation, I'll generally use something like y5k to copy what I just wrote. I ...
2
votes
1answer
139 views

Backward motions in Operator-pending mode move cursor

If i type, for example, y/foo<CR> in Normal mode, i "yank" all the text until the next occurrence of "foo" without side effects. However, if i type y?foo<CR> in Normal mode, i "yank" the ...
2
votes
2answers
189 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
2answers
73 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} ...