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
1
vote
3answers
142 views

Selector for line of text?

To grab a full word from anywhere in the word I can do: viw And to grab an entire line from start to finish I can do: V However, is there a section that grabs all text from the first char to the ...
1
vote
2answers
493 views

Replace a word in a stream of words separated with underscore

Does anyone know a quick shortcut I can use to replace a word in a series of words connected with underscores? Given: Create_in_one_of_these_words I want to make, where | is cursor: Create_in_|...
1
vote
2answers
28 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. ...
1
vote
2answers
80 views

How to change f{char} to search left if no char was found searching right?

Regarding this command: f{char} To [count]'th occurrence of {char} to the right. The cursor is placed on {char} |inclusive|. {char} ...
1
vote
2answers
342 views

Philosophical question: Is remapping keys to allow navigation in Insert Mode bad practice? In fact, why even have Normal Mode? [closed]

I decided to remap the arrow keys to C-h, C-j, etc. in my vimrc. Then I decided to allow half-page scrolling (which I use a lot) with C-u and C-d. But now I'm realizing that I rarely use hotkeys in ...
1
vote
1answer
175 views

ci[ ; bracket recognition fails

i have the following Text in my vim ('|' is my cursor.: "|--------------[ LatexBox ]------------- When i press ci[, nothing happens. I would expect that it doesn't matter where exactly in the line ...
1
vote
1answer
25 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.
1
vote
1answer
28 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 ...
1
vote
1answer
28 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=...
1
vote
2answers
86 views

Changing content within the specified [count] number of braces for each line

I need to change the content within a [count] number of braces for each line in my buffer. 1 {Lorem} ipsum dolor {amet} blah blah {change this text} more blah blah 2 Hello. The {sun} rises in {the} ...
1
vote
3answers
106 views

mystery cursor motion

I hope someone can riddle me this one: I have set up the function below to have a slightly more fancy behavior of the End key, moving first to the end of the line, but if the cursor is already at the ...
1
vote
1answer
46 views

Make pipe behave like `col('.')`

So when I go to the first character in a line, the first character in that line is a tab character, and I execute echo col('.'), I will get 1. However when I type 2| I won't go to the next character, ...
1
vote
2answers
692 views

How do I get matchit to work with '/>' (self-closed tags)?

I really like to jump from one <el> to the end of </el> with matchit. I am using it for jsx, but it does not seem to work if I have an element that is declared with />, does anybody ...
1
vote
1answer
80 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 ...
1
vote
1answer
26 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 -- ...
1
vote
1answer
19 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?
1
vote
1answer
144 views

Unexpected behavior with feedkeys

Consider the following code snippet, which aims to provide y without moving the cursor. function! Yank_fixed_cursor() let save_cursor = getcurpos() call feedkeys("y", 'nitx') call setpos('...
1
vote
4answers
48 views

How to end selection at an occurrence of a word?

Let's say I have this text with | as my cursor: <<<<<<< HEAD hi ======= hello ====== >>>>>> XXXX GGg| Now, I'd like to select from >>>> to say second=== or ...
1
vote
3answers
850 views

how to have a new line from within brackets

I normally write my functions this way public void test() {} to continue, I need to insert a new line from within the brackets, so the final output is this: public void test(){ // cursor is ...
1
vote
1answer
98 views

Why is :execute required in this --remote-silent command?

Let's say I want to jump to a particular position in a file in an existing Vim server: This command jumps to the correct line, but not the correct column, leaving the cursor at the start of the line: ...
1
vote
1answer
62 views

Act on lines changed by previous command

Is there a way to target the set of lines changed in the previous command? Say I do a search and replace, bulk indent, or some other command that affects either a series or scattered collection of ...
1
vote
1answer
84 views

How can I execute a command with a motion to the next/previous number?

I want to essentially be able to use a command similar to dt#, where the # represents any numerical character. My use case is modifying a script where I have a few server instances with long names ...
1
vote
1answer
95 views

How to write literal for Tab key to use for motion?

I've the following dummy file created via: echo -e "a a\tb b\tc c" > file Is there any literal for space which I can use for motion argument? For example this works (which removes the 1st a a ...
1
vote
1answer
50 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)....
1
vote
1answer
47 views

How to wrap a command which can handle a text object?

The scenario is that the plugin I use (iron.nvim) has a mapping crt which handle text objects. Ultimately, this mapping is based on a command <Plug>(iron-send-motion). I would like to create a ...
1
vote
1answer
120 views

How to create new operator by using existing operator with current motion?

function! OperatorFunc(type, ...) " how to call another operator with current motion? " do other stuff endfunction Is it possible to get motion text? such as get iw from yiw
1
vote
2answers
166 views

visual line mode is ended by inner block motion

When I do Vi{y to select inside a { block and yank it, it doesn't paste how I expect. I noticed that after V (which puts me into VISUAL-LINE mode), the i{ object takes me into VISUAL mode. Here's a ...
1
vote
1answer
102 views

Why doesn't "normal! lb" on last character of line move to beginning of word?

Let's say I have the text: foo bar baz With the cursor on z, I would expect :normal! lb to move the cursor to the first letter of baz. In actual fact the cursor does not move. However typing :...
1
vote
1answer
2k views

how to remap backtick mark with single-quote mark globally [duplicate]

I want to swap ' with ` for all combinations of commands in normal mode. I have tried the following: nnoremap ' ` nnoremap ` ' It works for commands like '', ``, but failed for d'', y'', etc. ...
1
vote
1answer
106 views

How do I apply the Lowercase action to a line movement?

From the vim-as-language article: Vim’s "verbs" mostly fall into 2 main categories. Some of them act on a single character, and others act on a "motion" or "text object". And from the vim wiki for ...
1
vote
2answers
276 views

Prevent the cursor from moving to the top of the file

I started using Seeing is Believing and updated my vimrc: nmap <leader>s A # => <Esc>:%.!seeing_is_believing --timeout 12 --line-length 500 --number-of-captures 300 --alignment-...
1
vote
1answer
149 views

wrap breaks when using delete or change word type commands

Using these options set wrap linebreak nolist set showbreak=~ "adds specified character after wrap set breakindent "forces word wrap to start at last lines indentation level set display=lastline "...
1
vote
0answers
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: ...
1
vote
1answer
59 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> ...
1
vote
0answers
21 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 ...
1
vote
0answers
33 views

A quick way to restore motion after changing iskeyword

I want iskeyword to only affect completion. I need that in the case of Latex. I want \chi_{23} to be a single object with regard to complition. But changing iskeyword also makes \dosomething{crap} a ...
1
vote
1answer
55 views

Vim changing the text objects of " in a single line with less number of keystrokes?

Consider this situation, which I often follow in python and consider that my cursor is on the letter a of args: args = ap.add_argument("-i", "--texture", type = str, required=True, help="path of the ...
1
vote
0answers
54 views

Repeat previous square bracket command [duplicate]

I am using the ] commands (e.g. ]]) a lot and have a bunch of custom ones too. Is there a command that repeats the last such command, similar to how . repeats the last edit?
1
vote
0answers
27 views

]m moves to class definitions not method definitions inside nested classes

I am editing a java file. ]m takes me from one class to the next, instead of to the next method definition. How do I get it to take me between methods? Example: public class Baz { public class ...
0
votes
1answer
235 views

Delete to next search result?

I often use dt, but that only deletes to a character. Is there something like dt that lets me type in a search instead of a single char? I would want to delete from my current cursor to that first ...
0
votes
3answers
240 views

Add line at the end of text

I have 5000 text files in a folder with different names. I just need to add one more line to the end in all files. Example: HELLO HELLO HELLO HELLO I need make it HELLO HELLO HELLO HELLO abc ...
0
votes
2answers
1k views

How can I change/delete comments easily?

For commenting and uncommenting I now use the vim-commentary plugin, also the NERD commenter can be used as mentioned in: How to comment out a set of lines which are selected in visual mode? I would ...
0
votes
1answer
156 views

(how) can I use di< / di> to delete inner block of xml

What would be the best way to delete / change the inner block of an xml element? I could use df< when my cursor is inside the block, i.e. when I have: <elem>foo bar<\elem> ^ ...
0
votes
1answer
585 views

Gotchas for changing spacebar to insert a space?

I find that one of my most common actions is to insert a space, therefore I am thinking about changing the spacebar to insert a space. Right now I rarely use the space bar in normal mode, which is ...
0
votes
1answer
307 views

Goto First line of page

I know to go to the last line of the page i use L. How do I get to the first line of the page ? or what is the opposite of L
0
votes
1answer
118 views

viw breaks when i is remapped

I have the following in my init.vim (neovim): nnoremap i k nnoremap j h nnoremap k j xnoremap i k xnoremap j h xnoremap k j nnoremap h i nnoremap H I I find this arrow key-like configuration much ...
0
votes
1answer
91 views

Delete from the next character till EOL

My problem Consider the following line: I have just pasted @SrvrlessDaysTLVtlv before tlv@serverlessdays.io, and I'd like to delete anything from the small-case t till EOL. What have I tried d$ ...
0
votes
2answers
39 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 ...
0
votes
1answer
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 ...
0
votes
1answer
42 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 ...