Questions tagged [cursor-movement]
Moving the cursor another place in the buffer.
243
questions
0
votes
0answers
12 views
Why doesn't my Numpad work on the terminal? [closed]
I hace a macbook air.As you know, the laptop does not have its own numpad. I also connected a keyboard with usb. While the numpad of the keyboard is working in other parts, the visual studio does not ...
2
votes
1answer
54 views
+50
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 ...
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 ...
2
votes
1answer
26 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 ...
-1
votes
1answer
32 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 ...
1
vote
1answer
41 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>
...
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
38 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?
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
96 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
84 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,
...
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
54 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,...
2
votes
1answer
87 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
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
30 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
59 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
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
83 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
49 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
62 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
733 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 ...
2
votes
1answer
140 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 ...
1
vote
2answers
105 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
2answers
167 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 ...
1
vote
1answer
112 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
250 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,...
2
votes
1answer
62 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
26 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
75 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
49 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
67 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
54 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 ...
1
vote
0answers
83 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
61 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
648 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
112 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
50 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 ...
4
votes
1answer
758 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
129 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
93 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
115 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):
...