Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

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

How to jump to the first character of the first line of the next/previous block of text?

I am aware of {and } to navigate between blocks of texts , however these jump to blank lines in between blocks of text. When there are several blank lines in between 2 blocks of text these do not ...
1
vote
1answer
27 views

Typing d in insert mode briefly moves cursor backwards

In Vim, when I'm in Insert mode and hit d, the cursor moves back one spot for a second, then jumps back to behind the letter just typed. This is quite distracting when typing texts. It looks like Vim ...
0
votes
1answer
27 views

How to bind these keys to prevent recursive binding in Vim?

I have been trying to do :noremap j k and :noremap k j which works but instead of going up it goes slanted up and down. I want j to move up and k to move down which is opposite in vim. I also tried :...
1
vote
1answer
24 views

Is there a way to use a relative address that doesn't go over the edges of the file?

I'm using the following commands to move a line of text up and down in the file. :move +1<CR> :move -2<CR> However, these commands don't work on the edges of the file. If I try to move ...
1
vote
1answer
23 views

How do I, in a macro, yank a word which might be just one letter long?

I am writing a macro a part of which is supposed to extract verse numbers from a string such as 11.1, standing for "verse one in canto eleven". I search /11\.\zs. The cursor now is in the right place. ...
0
votes
2answers
26 views

Why do I have to press the caret button twice to go to the beginning of the line?

When I press the caret button in normal mode, vim first prints a caret at the cursor position. Only with the second press of the caret button does the cursor actually move to the beginning of the line....
2
votes
1answer
48 views

Put cursor at arbitrary line and column

Normal, insert, and visual modes restrict cursor movements to locations occupied by some characters. They don't allow moving to the right from the end of line and down beyond end of file. For example:...
1
vote
1answer
35 views

How to move past a closing parenthesis in insert mode

so I've been learning vim the past few weeks and am having trouble with defining functions and the such. e.g. every time I define I function in python I write: typing in insert mode: def foo<...
4
votes
2answers
697 views

Why isn't this implemented by default in vim? (line by line Scroll) [closed]

Very often, my preferred way of navigating a file in vim is by "scrolling" line by line. By scrolling, I mean shifting the lines up/down while keeping the cursor on the same line and position. <c-d&...
2
votes
1answer
45 views

Go to Nth character in the file?

:goto goes to Nth byte of the file. I am looking for a way to go to Nth character. Given that Vim supports all kinds of multi-byte encodings, it would be odd if it did not exist, but I can't find one.
0
votes
1answer
25 views

Is the pattern .\{-}\> equivalent to the move command e?

What is the appropriate way to make a pattern that matches up until the point where the move command e would have moved to? Consider this text: texttext%0s: cookie after performing /%<CR>ve the ...
1
vote
2answers
40 views

Advance to next (multi)characters on a line

To advance to the next/previous character match on a line I can do: f <char> However, I find myself wanting to match against two characters on that line, for example, something like: f =' Is ...
3
votes
1answer
60 views

Simple keycombination to move to the last occurance of a character in a line

I am looking for a simple few key command which would move till the last occurrence of a character in the line. Is there anything already existing? The alternative is to jump to the next specified ...
0
votes
1answer
40 views

How to move the cursor out of the terminal

I'm now using Vim 8 and its new feature: :term. Well, it's great but I don't know how to move the cursor out of the terminal without the mouse. In Vim 7, we can type <C-w><C-h>, <C-w&...
1
vote
1answer
39 views

Does Vim keep track of screen views?

In vim, one could describe the "state" as the position of the cursor, the position of the screen view (ratio of screen viewable above cursor vs below), and the values of all latent variables and file ...
0
votes
2answers
37 views

Paste at cursor instead of below

If I start with this file: https://example.com <> and press ddp, I expect to get this: <https://example.com> but instead I get this: <> https://example.com What am I doing ...
1
vote
2answers
84 views

Pressing Enter removes indentation

If I have a file a.js like this: let a1 = [ ]; and I press Enter at the end of the first line, a Tab is inserted. I do not want this, so I added a setting: filetype indent off but then if I have ...
1
vote
0answers
26 views

Remove 'jumps' when moving to last and first line in Vim

I have the display option set to lastline so that the last line is shown even if all it doesn't fit on the window. When moving down visual lines with gj to the last line that is only partially visible,...
2
votes
1answer
60 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
25 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
67 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
38 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
54 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
49 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
56 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
58 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
361 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
76 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
39 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? ...
3
votes
1answer
20 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
454 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
113 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
69 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
94 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
63 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
16 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
408 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
116 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 ...
1
vote
2answers
182 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
100 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
33 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 ...
2
votes
1answer
218 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 ...
2
votes
1answer
84 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
74 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
72 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
223 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
96 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
30 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
52 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 .....

1
2 3 4 5