Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

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

How to search & replace the word under cursor without changing position?

This question is related to Do a forward slash search but don't have vim immediately jump to the string? but is not a dup. I recently updated my Linux box (clicked on the "install updates" button ...
4
votes
1answer
21 views

Cursor Movement in y8k vs y8j [duplicate]

Why does y8j not move the cursor but y8k does move it up? What .vimrc entry would prevent yanking upwards moving the cursor?
2
votes
2answers
52 views

Jump to a specific line without moving the cursor horizontally

Consider you are editing the left table in Vim. Your cursor (■) is at Line 14, Column 12. Where you are now Move the cursor 11 +-------+-----+ 11 +-------+-----+ 12 | Name | Age | ...
1
vote
0answers
26 views

cursor position jumps to first non-blank character of line unpredictably [closed]

I'm using SpaceVim with Neovim, and often times I'd experience this cursor jumping issue (as if ^ has been pressed in normal mode) while using it. I doubt the bug is on the Neovim end, otherwise a lot ...
2
votes
3answers
43 views

How can I prevent Vim from centering the line under the cursor on `:edit`

Each time I want to save my work while editing a text file, I enter :write to save the file, and :edit to reload the file, with the side effect of resetting the undo/redo buffer. However, an unwanted ...
0
votes
1answer
40 views

Vim command 0 goes to second column instead of first one

When I press 0 in Normal mode, the cursor goes to the second column and not the first one. This is not the normal behavior stated in vim's :help 0. I have tried disabling the remaps to move between ...
0
votes
1answer
39 views

Can I use feedkeys() inside of a keyloop implemented by getchar()

I implemented a fuzzy filter, which accept a list argument, open a window with a scratch buffer whose content set to the list, then waiting for use input and do filtering. Here is why I ask this ...
1
vote
2answers
45 views

Move cursor and screen together

I am implementing a smooth scrolling function for <C-u> and <C-d>, which just sleeps for a few milliseconds and then moves the screen up (<C-y>) or down (<C-e>) one line: ...
3
votes
3answers
197 views

Moving to the end of the last word on a line

There are commands to distinguish between the beginning of a line (0) and the beginning of the first word of the line (^), basically ignoring leading whitespace. But I can only find one way to move ...
0
votes
1answer
35 views

Jump to nearest pair of brackets with %

I'm looking for a way to change the behaviour of the % key. I know by default it will move the cursor to the corresponding parenthesis or brace, but I'm wondering if I can have it jump to the nearest ...
2
votes
0answers
38 views

Best way to move cursor to start of variable declaration?

There are a lot of times were I have something like int x = someFunction(a, b, c); If my cursor is somewhere after the equals sign, is there a good way to put the cursor on the “s” in someFunction? ...
2
votes
1answer
12 views

Register CursorMoved on certain key press and disable when move to new line

I'm trying to write a function that will highlight searches performed with the f and F keys. I currently have a solution here thanks to @filbranden, but would like to further improve it to only ...
3
votes
1answer
235 views

Jump *to* end of paragraph?

I often find I want to quickly select all the characters in an aligned column, something like this: this.p = obj.['propery']; this.prop = obj.['proper']; this.proper = obj.['...
3
votes
3answers
100 views

How to go halfway into a line? Percentage navigation within a line

I know that e.g. 50% is a normal mode command to go halfway down a file, but [count]% is line-wise. How can I get to the halfway point of the line that my cursor is on?
3
votes
1answer
50 views

How to treat underscores as whitespace when skipping to the next word? [duplicate]

Let's consider an example where the cursor is at the beginning of the text one_two three. Underscores are treated as part of the word, so w moves right to the first letter of three. With set ...
1
vote
2answers
63 views

How to move a cursor to the last line with auto indent?

Assume autoindent is set, and you have the buffer below. Note the cursor is represented as I. for i in range(1, 6): print(i)I When you hit Enter key, you get this. for i in range(1, 6): ...
0
votes
2answers
53 views

Why does `:m+1` not move two lines down when `:m-2` moves one line up?

In the help for move: :[range]m[ove] {address} *:m* *:mo* *:move* *E134* Move the lines given by [range] to below the line given ...
1
vote
1answer
13 views

How to make comma and semi-colon direction-insensitive of the latest f,F,t,T command

I can customize the n and N keys to always search backward and forward respectively irrespective of what the last search direction was with the following commands: nnoremap <expr> n (v:...
0
votes
1answer
142 views

How to replace a word with spaces

Suppose I have the following text: This is a test of the emergency broadcast system What I want to do is delete the word "test" and replace it with four spaces: This is a of the emergency ...
5
votes
2answers
114 views

WORD movement across lines

Consider the following text snippet: value1, value2 Now, if the cursor is at (1,1) (the 'v' of value1), W takes me to (2,5) (the 'v' of value2) which is as expected. But if I do dW at the same ...
0
votes
2answers
50 views

How to get PageUp and PageDown to return to the exact same character?

Because the default Ctrl-B/F or PageUp/Down behaviour usually leaves the cursor somewhere other than where it started, I remapped PageUp and PageDown in my .vimrc to simply move up/down 25 lines. ...
2
votes
1answer
59 views

How to scroll two vertical splits at the same time?

I am not sure if it is even possible but, when I am working with vertical splits, sometimes, I want both of them to scroll up/down at the same time rather than using this combination: scroll down ...
-1
votes
1answer
29 views

how to move to the end of a string / beginning of string for a macro

i want to write a makro and need to know how i can move to the end and to the beginning of a string, respektively i want to visually select the link so that i can surround it with brackets. my line ...
1
vote
1answer
147 views

Keep relative cursor position after indenting with >>

Can I setup >> to keep the relative cursor position? For example, assuming the line is def fun(<cursor>): can I make >> result in def fun(<cursor>): ? Obviously, with ...
1
vote
1answer
57 views

How to get w word and b back to treat hyphens and underscores like spaces?

I currently have this in my vimrc set iskeyword+=- But when I press w or b my cursor skips over hyphens. Am I misunderstanding iskeyword? How do I get word and back commands to treat hyphens (and ...
1
vote
0answers
27 views

]m moves to class definitions not method definitions inside nested classes

I am editing a java file. ]m takes me from one class to the next, instead of to the next method definition. How do I get it to take me between methods? Example: public class Baz { public class ...
1
vote
0answers
67 views

I want to improve my cursor movement [closed]

The thing that slows me down the most when using VIM is getting my cursor to where I want it to be. How should I practise improving this? Are there tools that teach you movement tricks and force you ...
1
vote
1answer
59 views

Is there any `setvirtcol()`?

I'm looking for a way to precisely set the cursor position given a virtual column. Is there only :exe "normal! ".vcol."|"? NB: I need virtual columns as they're the only thing that I'm able to ...
3
votes
1answer
155 views

How to jump to a character offset in a buffer?

Vim has the command :goto to go to a byte offset in a buffer. Is there an equivalent for a character offset? If not, is there a better way to implement it than repeatedly testing the cursor's ...
2
votes
1answer
92 views

What is the difference between ^ and _ for cursor movement

They both seem to move the cursor to the first non-blank character of the current line and I wonder what was the reason for duplicating this functionality
1
vote
1answer
28 views

How to show cursor in the middle of the window despite being at the end of the file?

I am editing at the bottom of a file, but I want the line I'm editing to appear in the middle of the screen. Is this possible without adding a bunch of spurious newlines at the end of the file?
2
votes
1answer
49 views

In visual mode, how can I select to either the next section or the end of the file?

I'm having trouble selecting sections in a file in a visual mode macro to separately perform some action on each section. Here's an example file: [insert introduction here] ... .... ------ section .....
3
votes
2answers
67 views

cmake movement plugin

I'm wondering, if there's a way to move with % in CMakeLists.txt files between foreach and endforeach, if and endif, function and endfunction, … googeling I only found plugins that allow calling ...
2
votes
2answers
164 views

why ctrl-h and ctrl-l behaves differently in normal mode?

In normal mode, I tried CTRL-H and CTRL-L, and I found that the former worked while the latter didn't do anything at all. I wonder why their behaviors are not the same?
0
votes
2answers
173 views

Why is Vim pasting after the cursor?

I don't understand why is Vim pasting after the cursor; for example in this example (where the cursor is at the start): |The quick brown fox jumps over a lazy dog ^ I would like to exchange fox and ...
3
votes
3answers
863 views

Moving to an outer block

Does anybody know the command for moving to an outer block of brackets/parentheses? Lets say that my cursor is in the innermost bracket. I know that % moves to a matching bracket, but is there a ...
2
votes
1answer
55 views

change inner backslashed quotes

I know the ci" motion and others :changes, but I need something like a ci\" in order to change inner a backslashed quotes. Assuming * as the cursor position: a = "message says: \"fo*o bar\"" I would ...
0
votes
1answer
27 views

Template plugin(?) to jump to next occurance of '<++>'

I just noticed that my current box with vim is missing a crucial feature, but I am unable to bring it back. A long time ago I had a vim setup where I could press Ctrl+J (IIRC) and then my cursor ...
1
vote
2answers
77 views

How to remove a line and paste it at the beginning of a range

How to remove a line and paste it at the beginning of a range? line 1 line 2 line 3 line 4 xxxxxxxx For example, here I want to remove the 5th line and paste it before the first two lines, to change ...
1
vote
2answers
47 views

Changing content within the specified [count] number of braces for each line

I need to change the content within a [count] number of braces for each line in my buffer. 1 {Lorem} ipsum dolor {amet} blah blah {change this text} more blah blah 2 Hello. The {sun} rises in {the} ...
0
votes
1answer
60 views

`0` only moving to first “visible” column

I have a strange trouble with vim (8.0.95). My format options are fo=cq and nowrap. When I have a long line, which does not fit my terminal window, the view of the file does not include the first ...
0
votes
1answer
69 views

Jump to next semicolun

I can use fd to jump to the next d character. How can I jump to the next semicolun? f; doesn't seem to work. Also, for other special symbols. Thanks
42
votes
8answers
16k views

Why is using arrow keys in normal mode considered bad practice?

I have read it in many articles (e.g.) that it's a bad practice to use arrow keys in normal mode. Could somebody explain why is it considered a wrong practice, if at all?
2
votes
2answers
389 views

Why does “e” move you one character before the actual end of the word?

Maybe it was discussed many times (I strongly believe), but I could not formulate my question properly. So lets imagine we have this sequence of words: foo bar baz Applying 3e will move us onto: ...
1
vote
2answers
153 views

How to enable disabled movement keys in netrw?

Recently I started using and learning Vim. I turned off movement keys in my .vimrc file like this: noremap <Up> <NOP> noremap <Down> <NOP> noremap <Left> <NOP> ...
3
votes
2answers
176 views

How do I make Vim preserve column position when moving between lines?

I'm using one of Vim distribution called SpaceVim and everything is good enough except some details. How do I make spacevim to preserve column position when moving between lines? For instance - move ...
0
votes
2answers
240 views

How to make f{char} case insensitive?

Regarding this command: f{char} To [count]'th occurrence of {char} to the right. The cursor is placed on {char} |inclusive|. {char} ...
1
vote
2answers
70 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} ...
7
votes
2answers
3k views

How to go to end/get out of the parenthesis of a line in vim?

I read the solution answered in https://stackoverflow.com/questions/11037825/vim-get-out-of-parenthesis-brackets-etc. That is nothing but command A that takes away you in the end of line. But, my ...
1
vote
1answer
261 views

Make ctrl-j and ctrl-k work like they do in less?

I would like to use ctrl-k and ctrl-j to not only move the cursor up or down (by lines), but also to scroll the portion of the document that is visible. Effectively, leave the cursor where it is and ...