Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

Filter by
Sorted by
Tagged with
1 vote
0 answers
19 views

Custom Jumplist Behavior

I enjoy using ctrl-i and ctrl-o to quickly jump back large distances in a file. I would enjoy if this functionality could be extended to the in-line motions such as f, F, w, b, ... I understand that ...
cuppajoeman's user avatar
1 vote
4 answers
37 views

Rotate list of lines

Assume you have the following block of text (yes: I am using vim-latex, but this is not relevant): \begin{itemize} \item 1 % [[[ \item 2 \item 3 \item 4 \item 5 % ]]] \item 6 \end{itemize} My ...
brad's user avatar
  • 131
1 vote
0 answers
33 views

How to prevent cursor shift when using `<cmd>` (like `<c-\><c-o>`)?

I currently have inoremap <M-j> <C-\><C-o>gj in my config but I would like to avoid triggering all InsertLeave autocommand when doing this. inoremap <M-j> <cmd>normal! gj&...
0x539's user avatar
  • 197
1 vote
1 answer
72 views

"gi" doesn't work in my buffers. No error

I recently learned about gi. It doesn't seem to work in my PHP buffer. I get no error message. I expect gi to go to insert. I also write with markdown. In this buffer I get an error that says I do not ...
Vinn's user avatar
  • 781
1 vote
0 answers
51 views

gvim can be really slow to display the last typed character in VirtualBox. How do I fix that issue?

While working in an Ubuntu VirtualBox (host is also Ubuntu), gvim is being really slow at showing the last character I just typed, or, when I move the cursor up/down/left/right, it also takes 1 to 2 ...
Alexis Wilke's user avatar
1 vote
2 answers
216 views

How to toggle the cursor position between the beginning and the end of the line?

In normal mode, I'd like to press a key that behaves like ^ (move the cursor to the first non-blank character of the current line), unless the cursor is already there, in which case it should behave ...
ax ax's user avatar
  • 35
0 votes
0 answers
37 views

NERDTree window change during tab switch

Currently, when using NERDTree, I hit Ctrl-ww to navigate to my NERDTree window from my editing window. Then, I navigate to a file I want to open, and hit t to open it in a new tab. Now, when I want ...
cz1's user avatar
  • 1
0 votes
0 answers
34 views

Popup to show number of matches of a given string while in insert mode, and while completion popup is being shown

This is a follow up to a previous question. Thanks to that, I could come up with this augroup: augroup Foo autocmd! autocmd TextChangedI,TextChangedP * call <SID>foo() fun s:foo() let ...
Enlico's user avatar
  • 2,194
0 votes
0 answers
44 views

How can I get the number of matches of pattern without altering the search buffer nor moving the cursor?

My end goal is to be able to highlight all the matches of the word being typed and echo their number, but this question is about one specific aspect of this, which I've been having trouble with, ...
Enlico's user avatar
  • 2,194
1 vote
1 answer
121 views

Cursor position 'o' and 'O' insert command with count number

The default behaviour of the o and O when prepended with a count is to keep the cursor always at the bottom. I'm wondering if there's a native way to get the cursor at the top. The way I'm doing this ...
ranemirusG's user avatar
2 votes
1 answer
35 views

How to return to previous position in a line? How to CTRL-O in a line?

After pressing 0 in a line, how can I now jump back to where I just was?
minseong's user avatar
  • 2,323
1 vote
1 answer
786 views

Why did vi use hjkl instead of jikl?

I found this convincing history on StackOverlow: Vim uses hjkl because vi did. Vi used hjkl because its creator's keyboard didn't have physical cursor keys. Instead, the arrows were printed on the ...
minseong's user avatar
  • 2,323
3 votes
3 answers
441 views

How to select the next text object?

How can I move to the next text object? E.g. with cursor on the first , in {}, {}, {} ^ then calling va} selects the middle {}. This is the behaviour I want to be able to achieve consistently, even ...
minseong's user avatar
  • 2,323
0 votes
1 answer
79 views

Navigate between (form feed) sections

Background: Vim :help states that a section begins after a form-feed (^L) in the first column [*]. In normal mode ]] or [[ can be used to navigate to the next or previous section (respectively). ...
NaiveQuestion's user avatar
0 votes
2 answers
205 views

Vim substitution and keep cursor in place

I have a mapping in my .vimrc. It is the following: nnoremap q; :call Add_comment_css()<CR> And then I can run, say 10q; And then it will run 10 times. But my problem is that the cursor always ...
john-jones's user avatar
4 votes
3 answers
1k views

Vim: what are the fastest ways to get to the middle of some line close to where your cursor is located?

Let's say you have this text: sed -n '1,4p' Commas are used in every sed expression to target a range. It's part of some notes i have... The cursor is right behind the to, but I want to get the ...
user avatar
0 votes
1 answer
368 views

in normal mode, How to place the cursor at the end of the line just like how insert mode behaves?

Is there a way to set the cursor in normal mode to the end of the line? for example, |abcdefg to abcdefg| not abcdef|g Cursor moves one character backwards on exiting insert mode https://stackoverflow....
NoName's user avatar
  • 3
1 vote
1 answer
40 views

How to handle the unstable move result about 'e' and 'b'?

We know that the command w, e, b handle the movement about word. But I think the w is stable, since whenever you type w, the cursor always jump to the next word. But e and b not that stable, if the ...
lizhe's user avatar
  • 137
1 vote
1 answer
338 views

How can I restore the behavior where h and l stopped at the beginning and end of the line?

After quite some time of using Vim I wanted to switch to NeoVim and set it up with more IDE-like features. So I googled and took the first thing I found (LunarVim/nvim-basic-ide/), thinking I could ...
obvg's user avatar
  • 13
2 votes
1 answer
128 views

How to "Set previous context mark"?

From the vim manual: m' or m` Set the previous context mark. This can be jumped to with the "''" or "``" command (does not move the cursor, this is ...
pigeon's user avatar
  • 25
4 votes
1 answer
103 views

How to go to last change not made on the current screen?

I love g;, but often I find myself repeatedly doing g; until the screen changes. The reason for this is that I am often editing in two different places in the file. If I think ahead, I should set ...
scottkosty's user avatar
1 vote
2 answers
146 views

How to move to the beginning of visual line or to move to the last non-whitespace character of visual line?

What are the commands to move to the very beginning and to move the last non-whitespace character of the current visual line? Do they exist at all? Commands for normal lines Commands for visual lines ...
user90726's user avatar
  • 123
0 votes
1 answer
27 views

Is the older behaviour (easier to break out of search term entry) of / searches still available?

I remember older vim installations (in 2.4.x/2.6.x era linux distributions) behaving differently with / searches, often you were able to almost instantly follow the search up with an edit or movement ...
rackandboneman's user avatar
2 votes
2 answers
275 views

} Jumps { between paragraphs - why they work so strange?

Paragraph 1. Paragraph 2. Paragraph 3. Paragraph 4. Here is how } and { currently work for me: Put the cursor on the P of the 2nd paragraph. Press }. The cursor will jump to the position between ...
user90726's user avatar
  • 123
3 votes
1 answer
151 views

Remap a key only when in final line of a file

I want to remap a key, but I want the mapping to be active only when I'm in the last line of my file. Is there a simple way to do this? I would also like to do a similar thing when I'm in the first ...
Ignacio's user avatar
  • 133
0 votes
2 answers
181 views

can I map multiple presses of <any key>?

I want to make more use of fF to navigate, but find the f to be clumsy. Eg. jump to "a" is fa. Instead, I'd like aaa to map to fa, bbbto map to fb etc. Is there an easy way to do this other ...
pinoyyid's user avatar
  • 153
0 votes
1 answer
32 views

How do I move the cursor feely past the EOLs?

I vaguely remember I've read about this option and also tried it out, but I can't remember the name... It allows using l to move past the EOL, even though $ still brings you to the EOL, not to the ...
Enlico's user avatar
  • 2,194
1 vote
1 answer
43 views

How to have w,e,b-based motions handle underscores without using iskeyword?

Using Neovim 0.6.1. I use a lot of snake_case_variable_names and have a frequent need to navigate within their individual components instead of treating these names as a single word. Right now, the ...
jwav's user avatar
  • 121
2 votes
3 answers
96 views

How to remember and recall cursor position?

Imaging I'm editing some code, and I found a few words that I would like to paste at the current cursor position elsewhere in the file. I will go to them, yank them, but then how do I return back to ...
Andrew Savinykh's user avatar
1 vote
1 answer
120 views

A multiple movement of the cursor

For example the code below, 1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 3: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa The arrow key moves the cursor from one character to the left, ...
Hyunsoo's user avatar
  • 131
1 vote
1 answer
153 views

Ctrl+Arrows work differently in normal mode and in insert mode

For some reason, in my VIM there is a difference in behaviour of Ctrl+Arrow keys in normal mode and in insert mode. To demonstrate this, I edit the file which contents are: aaa.aaa,aaa/aaa!aaa@aaa#aaa$...
CoderFF's user avatar
  • 21
1 vote
1 answer
46 views

Unexpected behavior in edited vimrc: dropped out of insert mode when hitting empty line

sorry for the bad title. I could not think of how to better summarise the problem. I should also state, that I am fairly new to vim, so please be a bit considerate :). I made the following changes in ...
I.P's user avatar
  • 13
1 vote
1 answer
189 views

Next paragraph - don't skip lines with white spaces

When using { and } to skip to the next paragraph, the behavior is unpredictable since I can't see white spaces. I have tried to show line endings to see which lines have spaces, but I don't like the ...
nixlarfs's user avatar
6 votes
2 answers
2k views

Why is % part of a word?

I have come across this behaviour and the documentation does not make sense to me. Consider this sentence: I am 100% sure there is something I am missing. This is the next line. Pressing w takes me ...
Ference's user avatar
  • 61
2 votes
2 answers
2k views

How to speed up cursor movement?

When I hold the key k to move cursor up, is it possible to speed up the cursor movement? I know that I can combine number with command (like: 20k) to move up many lines, but sometime I just prefer to ...
Lai32290's user avatar
  • 275
0 votes
0 answers
49 views

Go to end of last pasted region

Sometimes `] works, but not after inserting some new text somewhere. How can I jump to the end (and/or start) of the last region of text I pasted with some variant of p? `] does not work here: vim --...
minseong's user avatar
  • 2,323
2 votes
4 answers
492 views

How to move cursor up to nearest upward smaller level of indentation

Imagine my cursor is where the ^ is in this document: { "first": [ { "second": { "third": [ "fourth" ] } }, {...
minseong's user avatar
  • 2,323
1 vote
1 answer
125 views

How to get H and L commands to work properly in command mode

In vim's command mode, when I type 'H' the cursor usually doesn't go all the way to the top of the window, and 'L' doesn't go all the way to the bottom. To investigate the problem, I created a 60-line ...
David Levner's user avatar
2 votes
1 answer
414 views

How do I undo a fold?

I noticed that when I fold some text with zf and then press u for undo it does not undo the fold but undoes the last text editing action. Is there a general-purpose undo command which also would undo ...
Julius Hamilton's user avatar
0 votes
3 answers
290 views

Is there a built-in method to jump to the next character after a tab character?

I am editing tab-delimited data in a plaintext file (that was originally a spreadsheet) and I'd like to quickly jump forward to the next entry, the character after the next "tab" character. ...
Julius Hamilton's user avatar
1 vote
2 answers
337 views

How to go to the nth-to-last character in insert mode?

Capital A in Vim takes me to the last character in insert mode, but can I go to the nth-to-last character in insert mode (or append mode) in vim? Example: this is some t|ext how to go specifically to ...
an4s911's user avatar
  • 111
0 votes
2 answers
403 views

How to move `n` number char <left> in vim command line?

My init.vim code autocmd FileType cpp nnoremap <F4> :RunWithFile ~/Downloads/ > output.txt && cat output.txt I want my cursor position to be exact 31 times <left> in command ...
Mega Bang's user avatar
  • 199
0 votes
2 answers
883 views

Is there a plugin for (neo)vim that allows to jump to a possition by label, similar to things like vimium do?

With some browser plugins like vimium, one can press a key and all links on the open webpage get labeled with a short combination of letters. If you then type that combination, the corresponding link ...
con-f-use's user avatar
  • 103
5 votes
2 answers
617 views

Restoring cursor to position before delete after Undo

This question is asked multiple places but none have an answer that works for me. I've tried: '' `` g; g, ; , Ctrl+o In a file add: 123456789 Move your cursor over 7 in normal mode, type d4h, press u....
d9ngle's user avatar
  • 163
4 votes
1 answer
914 views

How do I delete until (and including) the 2nd occurrence of some character?

Here's an example: console.log("basename of"path.basename(__filename)) console.log(path.dirname(__filename)) With my cursor on path in the first line, I've tried: dt2) but then my cursor ...
NeoZoom.lua's user avatar
  • 1,460
0 votes
0 answers
27 views

Jump to last change that was farther than X lines away

I'm looking for a command similar to g;, but that ignores changes that are close to the cursor (say, less than 5 lines away). When I'm editing some function in the middle of a file, I sometimes need ...
Benoît Faucon's user avatar
0 votes
1 answer
139 views

How do I move to the next/previous number [duplicate]

How do I move the cursor to the next/previous number? Ctrl-x and Ctrl-a can't be used since I have :set nrformats+=alpha.
Sebastian Nielsen's user avatar
2 votes
1 answer
66 views

Moving by word (w/b) and staying within the line

Background I'm attempting to remap the arrow keys to move by word while staying within the current line. I.e. I'm looking for a behavior similar to w and b, but that acts like h and l in the sense ...
mortelsson's user avatar
2 votes
1 answer
424 views

How can I center the cursor vertically after jumping to a line?

I often use :line to jump to a line number. How can I automatically center that line vertically after jumping? Essentially the same as running :150zz.
Calin Leafshade's user avatar
2 votes
1 answer
126 views

vimscript to skip a block of text with lines containing similar words

I need a little help with some vimscript-ing. I have a huge log file with multiple blocks of text resembling the following: [log file start] ... ... Information: Setting NDR rule shield_rule on net a ...
Rich's user avatar
  • 21

1
2 3 4 5 6