Questions tagged [cursor-motions]

Commands that moves the cursor. A motion command is used after an operator command to move over the text that is to be operated upon.

Filter by
Sorted by
Tagged with
0 votes
0 answers
27 views

How to undo expanding selection in Vim? [duplicate]

I have this code snippet: await sendtemplateemail({ recipient: invite.recipient_primary_email, templateid: 'd-******', templatedata: { inviteurl: `${process.env....
abbood's user avatar
  • 733
0 votes
1 answer
40 views

How can expand and contract visual selection from a tag block?

Say I have hierarchical markup like this: <div id="level_1"> <div id="level_2"> <div id="level_3"> watermelon </div> </div>...
Sasgorilla's user avatar
1 vote
1 answer
80 views

Why d$ and v$d behave differently

I'm wondering why d$ and v$d behave differently. d$ deletes from the cursor till the end of the line excluding the carriage return where v$d delete from the cursor till end end of the line including ...
Vivian De Smedt's user avatar
4 votes
1 answer
397 views

Why does `yW` yank until the end of the WORD, but `W` move to the next one?

My confusion started with realizing, that yW yanks a different region, then what vW selects, but I found this that explains about selection. But then I realized, that while yW will yank until the end ...
fbence's user avatar
  • 677
1 vote
1 answer
154 views

Does NvChad hijack the ; key?

I installed the NvChad kit a few hours ago just to try it out. In this setup, I appear unable to jump forward to the next occurrence of a character using the semicolon after the first character match ...
parisminton's user avatar
1 vote
1 answer
63 views

How can I sync cursor movement in two vertical windows of the same file?

I can vertically split windows for the current file by :vs. Is there any way that I can sync cursor movement in the two windows? E.g. if the cursor in the left window moves up two lines, I want the ...
cat's user avatar
  • 33
1 vote
1 answer
72 views

Is there a motion for "next capital letter", and if not, can I program one?

Title says it all. I could of course look at what the next capital letter in the word is and e.g. gtE but I'd like something that's: fewer keystrokes and more importantly easier to commit to muscle ...
wallefan's user avatar
  • 171
1 vote
0 answers
53 views

Paragraph motions in single-line buffer

This question looks at how paragraph motions behave when the buffer consists of only two lines. But what if the buffer has just one line? Both { and } move the cursor to the last character of the line,...
photon.engine's user avatar
0 votes
0 answers
25 views

Move to end of current inner paren/block [duplicate]

Let's say we have this little snippet here open, and the cursor is at the |: some_function(a[0], | some_other_function(a[1])); How would you best delete, change, or visually select the ...
DexieTheSheep's user avatar
0 votes
1 answer
80 views

ib i( i) builtin text object give confusing results (for empty blocks)

When I use vi( (or vib or vi)) to select the inner-part of brackets, everything works fine whenever there is some content but as soon as the brackets are empty or contain only linebreaks, the previous ...
Laurent''s user avatar
  • 103
1 vote
1 answer
25 views

Clean the placeholder text after multiple jumps

I am studying the book "Hacking Vim" by Packt publishing. In chapter 4 the author gives us an example of a template for HTML files. I followed the guide of the author. Created a file ~/.vim/...
user4035's user avatar
  • 157
0 votes
2 answers
86 views

How to repeat motions in general and in particular the ones defined in filetype scripts?

It is possible in Vim to repeat: Last edition with . Last substitution with & Last macro execution with @@ But how to repeat the last motion? The , and ; repeats the last f, F, t or T move but ...
Vivian De Smedt's user avatar
4 votes
1 answer
115 views

Why doesn't Vim recognize a pair of <\> as a single unit?

I'm kind of confused about why doesn't Vim accept di> operation on this piece of text: <This is a random text but has a backslash at the end\> but rather does on this: <This is a text with ...
nekomekoraiyuu'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
3 votes
2 answers
223 views

Vim yank from cursor position to end of nth line

I am trying to yank from my cursor posintion to end of nth line defined by a motion. So for the below text Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non quam et erat pharetra ...
gmtek's user avatar
  • 145
3 votes
1 answer
100 views

The default behavior of "di("

As is well known, di( deletes the contents inside a () block. When the cursor is not within a group of (), the cursor jumps to the near () group and delete the contents in it. Is there any way to ...
gaoqiang's user avatar
  • 143
0 votes
1 answer
32 views

What causes the forward word motion to have a delay when "mapleader" is set to space?

With the following mapleader I have a one second delay when performing a forward word motion (w in normal mode). Is there any way to prevent this? let mapleader = "\<Space>"
Matt's user avatar
  • 171
0 votes
0 answers
62 views

Is there a way to access the text currently being typed in insert mode?

From :help registers I know that the . register contains the last inserted text. However, thanks to the following autocmd, I have verified that it's content is actually updated after exiting insert ...
Enlico's user avatar
  • 2,194
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
1 answer
72 views

Permanent bottom margin

Is it possible to keep a permanent bottom margin in the editing area, so that the cursor never touches the very bottom of the screen? So that when the cursor goes all the way down, I can still see a ...
Kolya's user avatar
  • 5
0 votes
1 answer
74 views

How to make % motion work with quotes?

Is it possible to have % motion work with matching quote " or '? For example if we have text: "Lorem ipsum is placeholder text (commonly used in the graphic), 'print, and publishing ...
niekas's user avatar
  • 1,575
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
2 votes
2 answers
252 views

How can I use `:keepjump` with `gd`/`gf`/searches?

I know that plugin that can do it almost certainly exists. Or maybe I could use something like LSP for this. But I want to make my simple command, that will go to file with definition of component / ...
moskalenco_a's user avatar
0 votes
1 answer
42 views

Opfunc inserts text before cursor position sometimes

function! s:Surround(motion = "") abort let [_, l:start_row, l:start_col, _] = getpos("'[") let [_, l:end_row, l:end_col, _] = getpos("']") let l:before = &...
Big McLargeHuge's user avatar
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
1 answer
63 views

clever way to move words at the end of the line into braces

I repeatedly need to transform word into \edlemvar{word}{}{} or \edlemvar{}{}{word} More generally, it would be great to have a way to do this even if there are more words on the line than "...
Alex Roberts's user avatar
1 vote
1 answer
133 views

Word motion as though non-keyword characters were whitespace

I'm very new to vi, so sorry if this is a dumb question. I've recently learned about the list of keyword characters, and I've noticed that vi treats strings of characters not in that list as words ...
wallefan's user avatar
  • 171
0 votes
2 answers
86 views

What is an elegant way to delete until the first line?

I know that I can delete until the first character with dgg or until line 1 with d1 Shift-G. But I would prefer something conceptually elegant if possible. I guess I can easily just remap a single key ...
Julius Hamilton's user avatar
0 votes
0 answers
18 views

How can I have my mapping handle a count in a function? [duplicate]

I wrote the following filetype plugin. It comments out lines in shell scripts by typing <leader>c. The problem is when I execute the mapped command multiple times by writing for example 4<...
theerrormagnet's user avatar
1 vote
1 answer
343 views

Vimscript: how to detect selection of a text object in visual mode?

I'm writing what may become a plugin that needs to know what is currently visually selected. To do it, I'm using the autocmd CursorMoved event to detect the creation of visual mode selections on the ...
mattb's user avatar
  • 1,131
1 vote
1 answer
389 views

How can I use a variable line number with a command?

I want to move a line to another specified in a variable. So where I might do this to move the current line up seven lines: :m-7 I want to do it with a variable line destination. Something like this: ...
markling's user avatar
  • 379
1 vote
1 answer
460 views

How to delete everything after the cursor

Say the cursor is []: A very intelligent turtle Found programming [U]NIX a hurdle I want to achieve the same thing as l D in one go: A very intelligent turtle Found programming [U] Is there any ...
mcp's user avatar
  • 169
7 votes
1 answer
2k views

Vim normal mode: why is j/k jumping paragraphs instead of lines?

So i've copied and pasted text from my browser, and when i hit j/k, it does not bring the cursor up/down single lines like it's supposed to: COLLEYVILLE, Texas (AP) — The rabbi of a Texas synagogue ...
user avatar
4 votes
1 answer
730 views

How do I delete a self closing html tag?

I'm trying to delete self closing html tags, like the img tag below. <div><img src='http://mypic.com/1.jpg' /></div> I've tried dit, dat, the tpope/vim-surround plugin, and other ...
Damien Sawyer's user avatar
3 votes
1 answer
108 views

How to insert to the beginning of a word with one key stroke?

Is it possible to start insertion in the beginning of a word when standing in the middle of it with a single keystroke? Currently I am using bi or Bi, but it does not allow me to use . to repeat the ...
niekas's user avatar
  • 1,575
9 votes
5 answers
3k views

How to append to the end of word with one key stroke?

Is it possible to start insertion in the end of word with a single keystroke? Currently I am using ea, but it does not allow me to use . to repeat the same action. I really love A and I which operate ...
niekas's user avatar
  • 1,575
0 votes
1 answer
53 views

How to select a whole line except beginning tab/space and last enter?

I'm dealing with the following text and want to select "abc def": 123 abc def 456_4 I've tried viw but it can only select a whole word isolated by spaces, and v$ starting with ...
Mactarvish's user avatar
0 votes
1 answer
73 views

How do you move to the end of the previous line?

Say the cursor is []: A very intelligent turtle Found programming [U]NIX a hurdle I want to end up here: A very intelligent turtl[e] Found programming UNIX a hurdle If I were here: A very ...
mcp's user avatar
  • 169
2 votes
0 answers
67 views

Make Lightspeed work with Repmo

I'm trying to make the EasyMotion-like (cursor jumping) Lightspeed plugin work with Repmo which repeats a previous motion. So far, (and after many hours), I've come up with the following: let g:...
Tom Hale's user avatar
  • 2,691
2 votes
1 answer
52 views

ci" changes between the wrong quote pairs

For instance, if the cursor position is right after one of the two commas: var strains = ["omicron", "delta","alpha"]; the ci" command deletes the content of ",...
Taro's user avatar
  • 153
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
2 votes
1 answer
214 views

How can sentences be handled by a motion?

Is there a motion to move forwards a sentence? For example, w moves forwards a word.
Tyler Durden's user avatar
  • 2,101
3 votes
1 answer
66 views

Stop word motions from overshooting line

The word/WORD motions w, W, e, and E will overshoot to the next line when the cursor reaches the end of the current one. The word/WORD motions b, B, ge, and gE will overshoot to the previous line when ...
Luiz Martins's user avatar
1 vote
1 answer
41 views

Execute action to the beginning/end of a motion

Is there a way do execute an action (change c, delete d, and so on) to the beginning or to the end of a motion? For example: Suppose we have: Praesentium officia mollitia iste molestiae ipsa qui ...
user avatar
0 votes
1 answer
44 views

Why does the cursor advance to the next character?

I have nnoremap Y y$ in my .vimrc. If I type "*y$, my cursor stays in the same spot on a word. However if I type, "*Y, the cursor is advanced one character. Why is that?
Harv's user avatar
  • 219
0 votes
1 answer
68 views

Inconsistent behavior of dj and other motion-delete operations

I'm running Neovim 0.5.0 locally. I'm going through Harvard's CS50 course and they have an IDE (accessible here: https://ide.cs50.io/) with a shell that's running this version of Vim: version 8....
Jordan Mandel'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
4 votes
2 answers
549 views

how to jump to start of tag

I might have some text like the following: <foo>something very important</foo> 1 2 ^ 3 4 If the cursor is inside the tag, for example on the m character, what is ...
john's user avatar
  • 183
3 votes
2 answers
489 views

removing multiple lines - d3d vs 3dd

I was speaking with my friend about removing multiple lines while using vim. They said they use d3d to remove 3 lines, whereas I use 3dd I understand my command is: 3 (repeat 3x) dd (delete the entire ...
Crusty's user avatar
  • 133
1 vote
0 answers
41 views

How to do a motion without leaving history (in .)?

Often, you do a complicated motion, which you want to repeat soon by pressing . but carry out a simpler motion overwrites that one. Can I keep that complicated motion in . itself ? Concrete example: ...
4amvim's user avatar
  • 43

1
2 3 4 5 6