Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

Filter by
Sorted by
Tagged with
2
votes
1answer
393 views

Move back the cursor after a “cw” command

I use quite a lot cw to change a word. I put the cursor on the start of the word, then cw followed by the new word and then <esc>. So far, so good. My problem is that after that the cursor is ...
4
votes
1answer
760 views

Keep Cursor In Current Position After Find-Replace

How does one keep the cursor in its place after a file-replace using :%s/find/replace/g ? I looked at restoring cursor position, but not quite what I was looking for, and I could jump back to previous ...
4
votes
1answer
131 views

How can I make a down movement at the last line go to the end of the line?

In some editors, if you press ↓ while in the middle of the last line, it takes you to the end of the line (or, equivalently, the document). I have grown somewhat used to this. How do I obtain the same ...
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 ...
18
votes
5answers
4k views

How do I move the cursor to the center of current line?

Is there a way I can move my cursor to the middle of the current line? (the middle of the line of text - not middle of screen width) I was wondering if there was a shortcut similar to M that moves ...
2
votes
1answer
113 views

Is the current behavior of `ge` in Operator-pending mode a bug?

When motion ge is used with an operator, such as d, the operator acts not only on the current character (which is just inconvenient -- i would prefer that the current character be excluded), but also ...
1
vote
1answer
102 views

How can I append after a code block?

I'm writing code like this: if (!p){ return 0; <-- cursor is on this line } And I want to start appending immediately after the code block, like this: if (!p){ return 0; } <-- cursor ...
3
votes
0answers
264 views

j and k keys not working like they should [duplicate]

I'm using gVim on my Windows 8.1 computer with a standard QWERTY keyboard, and neither the j and k keys, nor the Up and Down arrow keys let me move up and down in my text field while in normal mode. h ...
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 ...
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 ...
2
votes
1answer
929 views

How to scroll through a really long line? [duplicate]

My web service log file has a line that's 34151 characters wide (lots of Soap XML). When wrapped it fills more than 1 screen. How can I scroll it smoothly in vim? Using navigation keys like $ and w ...
19
votes
3answers
1k views

How can I make Vim position the cursor at the start of a tab character instead of the end?

Open an empty buffer and insert a tab character then exit to normal mode. When you place the cursor (normal mode) on the tab it will be at the right side of the whitespace. I'm looking for a way so ...
9
votes
2answers
2k 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. (...
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 ...
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?
4
votes
3answers
2k views

How do I switch around 2 pieces of text?

I have 2 pieces of text, what is a proper way to switch those pieces of text. around e.g. I have this: This is one piece of text. Here is another sentence. And I want to switch around the 3 first ...
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 ...
12
votes
1answer
2k views

Why does the cursor move to the start of the line after <Esc>?

I've noticed while editing along a line in a .txt file in insert mode the cursor will move to the start of the line following a write using key sequence: <esc>:w I'd like to change this ...
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 ...
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?
8
votes
1answer
354 views

Motion for moving to non-top-level Python function definition

I'm looking for something like [[ (or [], ]], ][) that works with non-top-level function definitions instead of the next line with a top-level class or function definition on the first character. ...
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 ...
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: ...
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 ...
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 ...
6
votes
2answers
2k views

How can I restore the cursor position when opening a file?

If I edit a file with vim that I have previously edited, I'd like vim to jump to the position I was in when I last closed the file. How can I accomplish this?
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
1answer
4k views

How can I move the cursor to the top or bottom of the screen?

I know that gg and G can move the cursor to the top and bottom of the file. But is there a way to jump to the top or bottom of the visible window?
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. ...

1 2 3 4
5