Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

Filter by
Sorted by
Tagged with
6
votes
2answers
3k views

Vim jump between words and stop at end of line

In normal mode, b and w are jumping between words, and I would like to stop at the end of line. For example: The cursor is right over here When I press w, what I expect is Instead, the cursor ...
5
votes
1answer
159 views

How to move around comments in any type of file?

In $VIMRUNTIME/ftplugin/vim.vim, some mappings are installed to move the cursor to the previous/next comment: " Move around comments nnoremap <silent><buffer> ]" :call search('^\(\s*".*\n\...
1
vote
1answer
152 views

Automatizing cursor movement in normal mode

Beginner Vim user here. I already learned about automating deleting with commands, which happens this way: [number]d[j/k/h/l] [OR] d[number][j/k/h/l] Where number stands for the amount of the ...
21
votes
5answers
2k views

Delete until the right end of the current inner block

Let's say that I have a code like this (| represents the cursor position): func1(x|, func2(), y); I would like to get: func1(x|); Is there a way to delete the code from the position of the cursor ...
1
vote
0answers
171 views

In Vim what is the reason that ce and cw are the special case to be the same if the cursor is on a non-blank?

Why not just let the meaning of w in cw the same as in dw? I means the w in dw for me is at the next word's start. Does it make something more convenient or just more complicated? If the latter, I ...
1
vote
1answer
106 views

ci" - change at the closest quotes (not on the same line)

I've been using Spacemacs recently and I am trying to reproduce one nice feature that I've seen there in Vim. Currently: ci" will change everything inside double quotes (cursor does not have to be ...
17
votes
4answers
2k views

How to replace inner text with yanked text

An editing pattern I frequently run into is the following: I want to yank a piece of text inside quotes or brackets, and replace that piece of text inside another pair of quotes/brackets. For example,...
16
votes
4answers
5k views

Scroll a quarter (25%) of the screen up or down

I often find scrolling a full page too disorienting, half a page too much, but a quarter page is just right. I currently do it just by holding down the arrow keys. How do I scroll 25% of the page ...
12
votes
1answer
817 views

Why does >3k move the cursor up when >3j does not move it down? [duplicate]

Hitting >3j indents the current line and the three below it, and >3k does the same but with the three lines above. However, when indenting down, my cursor is left on the same line as it started, ...
0
votes
0answers
1k views

Vim bind ctrl arrow key not working on osx

I know they have many topics about that, but i no one of them works. My configuration worked before to switch between split window, but my session has been re-init and i lost my osx config and it's ...
5
votes
2answers
391 views

Is there a way to use an ex command without moving the cursor?

I have relativenumber turned on and sometimes find it convenient to use ex copy/move/delete on certain lines. For instance, my cursor might be at the top of the screen and there are two lines I want ...
3
votes
1answer
508 views

How to go to the end of the line even in on a wrapped line?

I would like to map <End> and <Home> to go to the end or beginning of the current line (not the screen), even if the cursor is on a wrapped line: |1 First line. | |2 This is some ...
0
votes
2answers
252 views

Current line position when switching buffers

When switching buffers with :e# or <ctrl>-^, I commonly see the line with the cursor (the current line) move to the middle of the window (maybe related to the scroll_cursor_halfway function ...
3
votes
1answer
78 views

Map <number><cr> to go to the line

I have the following line in my config: map <cr> G So I can type 123<cr> and go to the line 123, but I don't really want to go to the end of file if I did not type any numbers. How do I ...
4
votes
1answer
1k views

Percent key ( % ) matching behavior for angle brackets ( < > )

In vi it's very helpful to be able to place the cursor on a '(' or '{' or '[' character, press the '%' key, and move to the matching ')', '}', or ']'. But this does not work for me with angle ...
2
votes
3answers
483 views

Cursor to last edit works, last position doesn't

From How do I jump to the location of my last edit? I can press: `. to take my cursor to the position of last edit but: `` doesn't take me to the last position of my cursor, as it says it should ...
2
votes
1answer
259 views

Move cursor from surrounds

What is best way to move cursor from the inside surrounds '"([{ (and other types)? For example, I'm typing if (condition) { body }. I've typed the condition, then I should go to body. For me it's ...
4
votes
4answers
762 views

Fastest way to delete part of word from end of word?

Let's say I have the following text and my cursor is on the "d" someCamelCaseWord ^ I want to delete "Word" so that the text reads "someCamelCase" What's the fewest number of ...
1
vote
1answer
125 views

How to navigate when using netrw-R (rename)

Often I rename files using netrw-R. It opens a rename confirmation on the commandline(?). E.g. Moving /home/ber/Documenten/xxx/xxx/test/services/member_balance_calculator_test.rb to : /home/ber/...
1
vote
1answer
78 views

ctrl+o and ctrl+i don't work with line skip motion 10j

I was very excited to see the relative line number feature in vim. Now vertical navigation would be a breeze, and instead of typing huge numbers, I can simply do 10j to move 10 lines down. However, ...
4
votes
1answer
83 views

Go to the last wrapped line with G

In Vim pressing G takes you to the last physical line. But, if the last line is wrapped around G puts the cursor on the first wrapped line in that last line, not the last wrapped line. So, is there ...
0
votes
1answer
896 views

How To Disable Backspace in normal mode

I have just started using vim. Due to that I don't instinctively hit the x/X key to backspace. This causes me problems as the backspace key moves you over as if you were hitting h in command mode. I ...
2
votes
2answers
418 views

Jump cursor vertically over code blocks. Keep horizontal position

I'm thinking about a feature which I think would improve my workflow a lot. I don't know if it already exists.. The feature is about moving the cursor vertically over code blocks without losing its ...
0
votes
1answer
166 views

Map movement keys to jump words like in non-modal editors [closed]

Coming from non-modal editors, I still get confused with e, w, b in Vim. One feature I like about non-modal editors is jumping words by simply combining Ctrl with ←→ arrow. So I thought I ...
0
votes
2answers
103 views

How to paste a line inside another line ? i.e. How to paste a line as words?

I would like to easily transform these two lines : One line. long line with many words in this example into the line : One long line with many words in this example line. How I currently do ...
4
votes
2answers
258 views

How do I keep custom cursor reset function from interfering with vim-template?

I have an autocommand function in my .vimrc that resets the cursor to where it was before I last closed the file. This function looks like this: function! ResCur() if line("'\"") <= line("$") ...
6
votes
2answers
157 views

What prevents the cursor from moving to the first column on some help files?

I recently noticed that on some help files it is not possible to move the cursor to the very first column of some lines. To explain it clearly, here is a screenshot where I have done the following: ...
5
votes
2answers
309 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 "...
4
votes
3answers
317 views

How can you indent your current file without losing your cursor position?

I was reading that the way to indent in vim is a gg=G sequence. This however loses my cursor position. How can I indent my file without losing my cursor position?
6
votes
1answer
220 views

Move unambiguously to the next position with changing rows

By pressing l you can move to the next position in a line. Unless you are at the end of the current line, in which case you won't move at all. Is there some simple way to automatically move to the ...
1
vote
1answer
62 views

% operator without using enclosing brace

When my cursor is inside a brace, e.g., (( "Hello World!⣿" )) where ⣿ is my cursor, and I use %, I will automatically select the first opening (. Is there some way to make the % only jump if it's ...
4
votes
1answer
58 views

Certain functionality doesn't work with `normal!`

I always have problems selecting visual areas with the normal! command in vim. Against all I expected, the following doesn't work: function! s:foo() normal! v/\S\<cr> endfunction nnoremap &...
8
votes
1answer
589 views

Move to next unmatched line with vimdiff

Is there a way to move to the next unmatched line with in vimdiff? Not "move to the next changed line", but move to the next unmatched line for the current file. In my case I'm trying to compare two ...
2
votes
1answer
109 views

additional input complication due to auto-match bracket in Vim

There are several plug-ins can accomplish this task, auto-add a closing bracket when we type: (, [ or {. But then the cursor will be in the middle of paired bracket, when we finish inserting, we ...
6
votes
2answers
737 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 ...
15
votes
2answers
4k views

How to restore the position of the cursor after executing a normal command?

I am trying to code a function that replaces the character in the sixth column of my current line with a dollar symbol ($), but I would like my cursor to remain at the position it was before calling ...
16
votes
2answers
5k views

How do I make Vim always display several lines after EOF?

In Vim, I don't like how when you reach end of file it puts the last line at the bottom of the screen. Is there anyway to make the last line be something like 10 lines above the bottom of the screen ...
2
votes
1answer
354 views

How to add numbered movement to the jump list?

I'm loving the fact that I can jump using relative numbers and a movement command but I always seem to find myself using the backticks to try and go back to where I was before the movement jump. I ...
0
votes
2answers
351 views

How to move the line under the cursor to the middle of the screen by scrolling (not automatic)? [duplicate]

For example if I have a line at the beginning of the screen and in the opened file there are other lines above it so the screen is not at the beginning of the file (it is scrolled down), if I go to ...
12
votes
4answers
3k views

Vim HardMode Fine Grain Movements

I recently found out about Vim hard mode and I've decided to try and use it. However, I'm running into some problems with fine grain movements. For example, let's say I really just want to move up or ...
5
votes
1answer
118 views

How do I jump back to the next-to-last insert position?

I can't find an easy solution to the following problem. Consider I'm in insert mode and I need to modify something in another point of the text. I exit insert mode and then move to the point I need ...
5
votes
2answers
258 views

Skip over character in insert mode, even at the end of a line

I have this map in my .vimrc: inoremap <C-space> <C-o>l So that, eg, if I'm in insert mode: I can just type <C-space> to move out of parens: It all works great in the middle of a ...
18
votes
5answers
1k views

After copying a visual selection to keyboard, return to original location

My cursor is in the middle of a paragraph when I decide suddenly I need to copy that paragraph: So I type vip to select the paragraph visually: Now I hit cmd+C to copy to clipboard (this may vary on ...
3
votes
0answers
49 views

After a while in a session, commands to change one character change two. Why? [closed]

After vim has been open for a while (on Ubuntu in a console), I notice that commands start behaving differently. Mostly, they'll change or delete an extra character. For example: 123456 ^ cursor ...
7
votes
2answers
226 views

Changing how the jump section `[` and `]` command works

:help section states: The "]" and "[" commands stop at the '{' or '}' in the first column. This is useful to find the start or end of a function in a C program. Is it possible to change the [ ...
4
votes
1answer
736 views

How to save previous cursor position inside a function which has received a range?

I have the following code in a file: function! s:TrimWhitespace() abort range " Save cursor position, because the following substitution will move it let save_cursor = getpos('.') " ...
5
votes
2answers
203 views

How to set incremental marks?

I'm used to set marks with m<char> where <char> is any character I choose and then reaching the marks with ]` or [`. I'm wondering if it is possible to use a command to set a mark with an ...
7
votes
1answer
150 views

Why is the previously inserted text reset after using an arrow key?

From help :help i_ctrl-a: CTRL-A Insert previously inserted text. {not in Vi} Let's say I have an empty buffer and I'm in normal mode. I type i to go in insert mode. I type (), then move the ...
5
votes
4answers
287 views

How to move inside vim's internal pager from a mapping?

I would like to use the normal commands g, and g; more often to navigate through the change list. The problem is I usually don't know how far I am in the change list from the edit I'm interested in ...
29
votes
4answers
16k views

How to disable arrow keys in vim?

I want to teach myself using hjkl more than using 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 ...