Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

Filter by
Sorted by
Tagged with
4 votes
1 answer
935 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 % to ...
Gonçalo Ribeiro's user avatar
3 votes
1 answer
83 views

Using the % command in c++

The % command is quite nice, and I use it to copy/delete whole loops, functions and classes. In c++ though, you need to add a ; after your class declaration, so trying to motion over a whole class ...
elyashiv's user avatar
  • 2,419
2 votes
2 answers
193 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 ...
elyashiv's user avatar
  • 2,419
4 votes
1 answer
464 views

How to resume previous multiple cursors?

I'm using multiple cursors plugin. I'm trying to do the same thing as the second example in their github page. Just trying to add double quote around each of the weekday: mon tue wed thu fri sat ...
Aaron Shen's user avatar
  • 2,439
1 vote
1 answer
82 views

Gvim doesn't remember cursor position within line if previous session ended on line 1

I noticed that whenever I quit Gvim, it will remember the line and position within the line that the cursor was on, unless the cursor was on line 1. If the cursor was on line 1, then it will not ...
pacoverflow's user avatar
8 votes
2 answers
288 views

What does [count]% do?

I would expect [count]% to jump back and forth between matching braces count times or something like that, but instead, typing that command seems to move the cursor to a random place in the buffer. ...
Daniel's user avatar
  • 183
2 votes
1 answer
194 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 ...
Alexey's user avatar
  • 511
2 votes
2 answers
148 views

How to add a string to cursor point of gvim through a shell script

When gvim is opened it saves the cursor position whether it is minimized or not. So I'm curious whether it is possible to add a string starting from the cursor blinking position by running a shell ...
ikisuru's user avatar
  • 23
2 votes
1 answer
456 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 ...
Rmano's user avatar
  • 748
4 votes
2 answers
1k 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 ...
KM.'s user avatar
  • 141
4 votes
1 answer
142 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 ...
muru's user avatar
  • 24.5k
7 votes
2 answers
1k 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 ...
Tom's user avatar
  • 1,230
23 votes
6 answers
6k 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? By middle, I don't mean the middle of the screen, but the middle of the line of text, regardless of length. The shortcut M moves ...
thameera's user avatar
  • 16.5k
2 votes
1 answer
131 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 ...
Alexey's user avatar
  • 511
1 vote
1 answer
140 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 ...
Daniel Kleinstein's user avatar
4 votes
0 answers
590 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 ...
Dante2's user avatar
  • 41
40 votes
1 answer
24k 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 ...
Christopher Bottoms's user avatar
24 votes
3 answers
2k 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 ...
bdesham's user avatar
  • 2,813
3 votes
1 answer
2k 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 ...
roblogic's user avatar
  • 697
20 votes
3 answers
2k 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 ...
Chad Paradis's user avatar
12 votes
4 answers
5k 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. (...
bsmith89's user avatar
  • 1,067
0 votes
1 answer
576 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 ...
Tomas Tomecek's user avatar
131 votes
3 answers
15k 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?
romainl's user avatar
  • 37.2k
5 votes
3 answers
3k 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 ...
nos's user avatar
  • 1,833
131 votes
6 answers
36k 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 ...
bdesham's user avatar
  • 2,813
14 votes
1 answer
4k 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 ...
Jim's user avatar
  • 265
9 votes
2 answers
2k 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 ...
Gonçalo Ribeiro's user avatar
69 votes
4 answers
23k 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?
kenorb's user avatar
  • 17.7k
8 votes
1 answer
455 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. ...
TankorSmash's user avatar
26 votes
1 answer
4k 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 ...
Jasper's user avatar
  • 505
6 votes
4 answers
693 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: ...
Karolis Koncevičius's user avatar
22 votes
2 answers
1k 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 ...
Martin Tournoij's user avatar
36 votes
8 answers
3k 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 ...
alxndr's user avatar
  • 1,356
7 votes
2 answers
3k 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?
user avatar
31 votes
4 answers
7k 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 ...
Martin Tournoij's user avatar
44 votes
1 answer
12k 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?
thameera's user avatar
  • 16.5k
31 votes
4 answers
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. ...
Reaver's user avatar
  • 593

1 2 3 4 5
6