Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

Filter by
Sorted by
Tagged with
2
votes
1answer
47 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
29 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
677 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
23 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
38 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
52 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
37 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
37 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
66 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
58 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
37 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
50 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
47 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
55 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
57 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
330 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
66 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? ...
2
votes
1answer
17 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
420 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
111 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
58 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
88 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
62 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
15 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
335 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
160 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
89 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
32 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
203 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
77 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
73 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
69 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
214 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
95 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
51 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
75 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
250 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
216 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 ...
5
votes
3answers
1k 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
57 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
28 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
2 3 4 5