Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
2 votes
1 answer
55 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 "...
user avatar
1 vote
1 answer
28 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 ...
user avatar
0 votes
0 answers
20 views

Plug-in to make sentence skipping based on NLP

Is there any plug-in which uses modern NLP sentence segmentation when deciding on the sentence boundaries, when skipping with )? If not, how could that be implemented? Because the sentence jumping I ...
user avatar
0 votes
1 answer
26 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 ...
user avatar
0 votes
0 answers
15 views

How to use advanced Regex features without too many syntax cluster

I have a bunch of typescript classes in a single file, each of them has an _update function. I want to go to _update function of a class Player. How would I do that? class Player { _update() {} } ...
user avatar
  • 145
0 votes
0 answers
19 views

How to prevent Esc+Home from jumping to line 3?

I have Linux boxes running a mix of Gentoo and Arch Linux with VIM version 8.2, and one CentOS box with VIM 7.4. When I use VIM in a GUI terminal most of them jump to the third line from the top of ...
user avatar
0 votes
0 answers
16 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<...
user avatar
0 votes
1 answer
49 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 ...
user avatar
  • 866
1 vote
1 answer
31 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: ...
user avatar
  • 211
1 vote
1 answer
84 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 ...
user avatar
5 votes
1 answer
882 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
1 vote
1 answer
58 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 ...
user avatar
3 votes
1 answer
72 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 ...
user avatar
  • 1,073
9 votes
4 answers
1k 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 ...
user avatar
  • 1,073
0 votes
1 answer
40 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 ...
user avatar
0 votes
1 answer
60 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 ...
user avatar
2 votes
0 answers
46 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:...
user avatar
  • 2,221
2 votes
1 answer
50 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 ",...
user avatar
  • 153
0 votes
2 answers
56 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 ...
user avatar
  • 111
1 vote
1 answer
30 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.
user avatar
  • 1,825
3 votes
1 answer
37 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 ...
user avatar
1 vote
1 answer
33 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
28 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?
user avatar
  • 199
0 votes
1 answer
45 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....
user avatar
0 votes
1 answer
64 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.
user avatar
3 votes
2 answers
186 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 ...
user avatar
  • 153
0 votes
0 answers
55 views

Cursor disappearing

I'm using pywal and the wal colourscheme and since enabling it my cursor seems to have disappeared, meaning it has the same colour as my background (that's what I guess) and I only see it blinking ...
user avatar
  • 101
3 votes
2 answers
280 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 ...
user avatar
  • 33
1 vote
0 answers
35 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: ...
user avatar
  • 43
1 vote
1 answer
109 views

Add current position to the jump list the first time <C-u> or <C-d> is pressed

I'm often using <C-u> and <C-d> to quickly navigate around in my code (I don't like using { and } since they're hard to type on my layout). One thing that annoys me is that <C-u> and ...
user avatar
  • 111
2 votes
1 answer
201 views

Fastest way to find last occurence of a character in line?

Say we have the following: echo 'This is a test'.$test1.$test2.$test3.$test4.$test5.'and this is another test'; ^ With the cursor being on the first dollar sign, and I want to ...
user avatar
  • 123
1 vote
1 answer
54 views

What is the correct cursor position when a } (forward paragraph motion) reaches the last line of the buffer?

Suppose I have two lines in a buffer: First line Second line I position my cursor on the first column of the first line. In normal mode, I press } (i.e. closing curly brace, forward paragraph motion)....
user avatar
  • 801
1 vote
1 answer
112 views

How does the underscore forward movement work? _f

I was recently watching a more advanced vim tutorial on youtube. One of the commands used was _f. This was actually just part of a longer macro being demonstrated and the underscore wasn't commented ...
user avatar
0 votes
2 answers
100 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 ...
user avatar
  • 3
1 vote
2 answers
266 views

How to add several empty lines without entering insert mode? [duplicate]

Sometimes I want to add several empty lines for better visualization. Now I end up clicking o<Escape> multiple times. I would love to reduce number of clicks by using something like 7o instead, ...
user avatar
  • 1,073
3 votes
1 answer
153 views

Backward search in current line with search() and z option

I am trying to write a couple of simple functions to find the next and previous links in Vimwiki and move to them. Links in Vimwiki are indicated with the syntax [[link to something]]. Since I only ...
user avatar
  • 255
0 votes
1 answer
17 views

Make j and k act character-wise when used with operators

When I use j or k with operators, they make the operator act line-wise - acting over two whole lines, as if I had used Vj/Vk. I want them to act character-wise so that they act until the current ...
user avatar
  • 111
1 vote
1 answer
34 views

Create mapping that works both with a motion and a count

I'd like to have a mapping that separates words, like this: noremap RJ :s/\>\s*\</\r/g<CR>='' I can do 3RJ with that. I can also create opfunc, so I can do RJ}: noremap RJ :set opfunc=...
user avatar
  • 113
1 vote
2 answers
29 views

make da( or dab remove lagging whitespace like daw

TL;DR: da( doesn't delete the following space like daw does. Can I make this do what I want easily? I have some sample lines (cursor is shown as |): 1. Sample line (extraneous| statement) in notes. 2. ...
user avatar
0 votes
1 answer
31 views

Line numbers relative to the screen

Is it possible to make Vim show line numbers relative to the screen? Not to the beginning of the file, and not to the current position of the cursor, but relative to the first line that is currently ...
user avatar
  • 111
1 vote
1 answer
29 views

How to prevent cursor shift when using <C-O>{delete cmd} at the end of a line?

<C-w> deletes a (small-)word in insert mode, but I often want to delete the Word (to last whitespace) I've most recently typed. I tried inoremap <C-_> <C-o>dB which kind-of works -- ...
user avatar
  • 325
-1 votes
1 answer
36 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 ...
user avatar
1 vote
2 answers
86 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> ...
user avatar
  • 111
0 votes
1 answer
44 views

G+zz simultaneously : Move to bottom and then move text to center?

How do i remap G to do what G and zz do simultaneously ? In other words, I would like to move to the bottom of the page and then have the text moved to the middle of the screen. I tried something like ...
user avatar
1 vote
1 answer
23 views

<esc>v$ without trailing space?

I want to use $ in visual mode but it always includes a trailing space (even if there isn't one on the line). How do I make it so $ only goes to the actual last letter?
user avatar
  • 167
2 votes
1 answer
46 views

Is there a motion to select the comment block under the cursor?

One thing that I often need to do is reformat a code comment with gq or gw. For example, I often want to convert something like this: // Lorem ipsum // dolor // sir // amet int foo(int x) { ...
user avatar
  • 193
1 vote
0 answers
24 views

Different Deletion from seemingly equivalent motions

I have been learning vim for some time now and I am loving it but there is something that confuses me a little bit. For discussion proposes lets say that we have the following text foo.bar with the ...
user avatar
  • 111
1 vote
2 answers
425 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....
user avatar
  • 153
4 votes
4 answers
352 views

What's the difference between a text object and a motion?

I've been using vim for a while and consider myself moderately proficient. I've also built custom text objects, primarily using the fantastic vim-textobj-user rather than natively, as well as using ...
user avatar
2 votes
2 answers
474 views

How to go back to the start of a visual selection?

I find myself often selecting text and then wanting to go to the start of that selection rather than the end. For example in the following: If I press esc, it will take me to the end of the selection,...
user avatar
  • 1,767

1
2 3 4 5