Questions tagged [cursor-movement]
Moving the cursor another place in the buffer.
246
questions
0
votes
2answers
27 views
Mapping with motion ip
I'm trying to create my own mapping with motion in Vim after reading this stackexchange question. I'm using the plugin vimtux to send code to specific tmux instances and I now want to be able to do ...
0
votes
1answer
21 views
Enter insert mode automatically after moving (e.g. with e, w)
Is there something similar to A and I for "smaller ranges" like w and e, i.e. I don't want to have to press i to insert, after navigating to the end of the word with e?
3
votes
1answer
50 views
How to move cursor to previous line automatically?
On nano&emacs&any other text editor, when the cursor is at the 1st character of a line (not the 1st line), press the left key and it will automatically jump to the last character of previous ...
34
votes
4answers
19k views
How to disable arrow keys in vim?
I want to teach myself to prefer hjkl more over the arrow keys in order to stay on the home row. (I am very aware that one should not use hjkl as the main navigation keys as there are more powerful ...
0
votes
0answers
45 views
Why C-0(zero) in insert mode is not working?
I have mapped some shortcuts to help me in insert mode and one of them is not working.
" Go to end of line on insert mode
inoremap <C-e> <C-o>$
" Go to beggining of line on ...
18
votes
3answers
10k views
Jumping to a byte offset, and displaying position as byte offset
How can I move the cursor to the nth byte in the buffer?
How can I display the current cursor position in the ruler in terms of the byte offset, rather than lines and columns? (Follow-up question: ...
2
votes
1answer
62 views
How to move to Markdown ATX-style headers?
How can I move (navigate) between Markdown ATX-style headers?
The Vim plugin https://github.com/gbgar/pandoc-sections.vim does so using the [ and ] keys, but only when there is no space between the ...
10
votes
3answers
2k 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. (...
2
votes
1answer
92 views
Conflict between system compose key and insert mode meta key mappings
I use the right alt key as a compose key on my system, to easily draw diacritics and accent characters.
In Vim, I unlock alt key mappings with this (from stackoverflow):
" Allow <alt> key ...
2
votes
1answer
38 views
Midline Shortcut for VI?
Is there a shortcut to take you to the midpoint or the middle of a line inside VI? Ctrl + A and Cntrl + E are super helpful, but I'd love something that's Cntrl + M or something to take me to the line ...
1
vote
1answer
42 views
Text object for a field between tabs
I'd like to define a text object for tab-delimited fields in a tsv file. So far, I have
vnoremap af :<C-U>silent! normal! T<Tab>vf<Tab><CR>
omap af :normal Vat<CR>
...
5
votes
3answers
394 views
Prevent the cursor from moving to the start of the yanked text?
Vim help's change.txt states that
Note that after a characterwise yank command, Vim leaves the cursor on the
first yanked character that is closest to the start of the buffer. This means
that "...
2
votes
1answer
27 views
Move cursor back to previous window after splitting
After running a command that opens a new split (e.g. :botright 10new), how can I have the cursor move back to its previous position? A use case would be to show a message in a scratch buffer without ...
2
votes
2answers
42 views
Delete the content and the brackets of a level above while inside in the inner level
My cursor is at H
{
//foo
{
//bar
{
//cursor is Here
}
//bar2
}
}
How do I delete the outer layer of brackets while keeping the layer where my cursor is intact? End result ...
0
votes
1answer
61 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 :...
8
votes
3answers
836 views
Jump to next identifier in Vim help files
I regularly find myself in the situation that I am reading a help topic and see an identifier (the blue underlined words) that I want to follow with <C-]>. However, most of the time the ...
-1
votes
1answer
33 views
In a new line, moving to the columns of the beginning of the words in the line above?
Is it possible to have a 'smart tab' working as follows: 'move forward to the columns corresponding to the beginnings of the words in the line above'
For example, in the situation below:
I would like ...
3
votes
2answers
194 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
23 views
Override a plugin to restore movement key?
I'm using the pencil plugin which remaps the jk movement buttons to go up/down by row (text is soft wrapped) rather than line, which is usually helpful. But at times I want to have the normal behavior ...
1
vote
1answer
42 views
How to have l and h at the boundary of the window shift only one column, when wrap is off?
How can I have h and l move the viewport only by one column when they go beyond the left and right borders when nowrap is active?
1
vote
2answers
89 views
Sync cursors of popup window and current window
I'm trying to sync the cursors movement of a popup window, and the current window.
call range(50)
\ ->map({_, i -> string(i)})
\ ->popup_create(#{
\ line: 1,
\ col: 1,
...
29
votes
4answers
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.
...
2
votes
1answer
21 views
Substitute: previous match with confirm
If I do a replace like this:
:%s/May/June/gc
afterward I keep hitting y or n as needed. But sometimes it hit n on
accident and need to go back. I read that you can use N for this purpose, but
it ...
2
votes
1answer
125 views
VIM - How to select multiple lines that are not adjacent?
If you have the following text:
line 1
line 2
line 3
You can hit CTRL+v on line 1 and hit j to select line 2. However, I want to select both line 1 and line 3, but not line 2.
Is this possible?
1
vote
2answers
59 views
Any ways to sync the movement of the number column and another window?
I want to be able to control/sync the movement (scrolling) of the number column (usable with :set number) with another different window (which doesn't have :set number set).
Any ways to do this?
5
votes
1answer
76 views
How often and when is foldexpr evaluated?
I want to toggle foldmethod between expr and manual because if we always set foldmethod=expr, then the cursor tends to move slowly in vim.
I think that foldexpr is evaluated just after switching ...
3
votes
1answer
56 views
Cursor-movement after $ motion
I play the great game called VIM adventures (from which are the images bellow). The question is from the game, but is also reproducible in VIM so this is the place I ask.
Assume you are in normal mode,...
4
votes
2answers
739 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 ...
1
vote
0answers
87 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 ...
56
votes
3answers
16k 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?
2
votes
1answer
13 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
31 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 ...
1
vote
1answer
28 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
24 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
111 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
51 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
85 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<...
6
votes
3answers
2k 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 ...
9
votes
2answers
1k 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 ...
2
votes
1answer
200 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
27 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 ...
108
votes
2answers
9k 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?
1
vote
2answers
127 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 ...
23
votes
4answers
5k 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 ...
19
votes
3answers
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 ...
1
vote
1answer
139 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
47 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
42 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
288 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 ...
2
votes
0answers
42 views
Remove 'jumps' when moving to last and first line in Vim [duplicate]
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,...