Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

Filter by
Sorted by
Tagged with
8
votes
1answer
683 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 ...
7
votes
2answers
8k views

How to go to end/get out of the parenthesis of a line in vim?

I read the solution answered in https://stackoverflow.com/questions/11037825/vim-get-out-of-parenthesis-brackets-etc. That is nothing but command A that takes away you in the end of line. But, my ...
7
votes
2answers
1k views

Go to the next word starting with specific letter on current line

I want to have the command which is stated in the title. I looked for it in intrinsic Vim command but did not find it. I ran some tutorial online about functions in vim, The idea would be to have ...
7
votes
4answers
2k views

How to change the behavior of cursor motions? (ex: go from one line to the end of the previous one)

I am relatively new to using vim. I have to admit it is a powerful tool, however it can be very frustrating if one doesn't learn how to use it. Whatever, there is one or two things that annoy me ...
7
votes
2answers
6k views

Move inside next quotes?

I have a file with several lines like so: {"latin": "", "french": "", "italian": "", "catalan": "", "portuguese": "", "romanian": "", "spanish": "", "english": ""} I want to quickly move between the ...
7
votes
2answers
1k views

Extend visual selection til the last character on the line (excluding the new line character)

In the visual mode the $ extends selection til the end of the line including the new line character at the end, so I need to press an additional h to exclud the new line character. Is it possible to ...
7
votes
1answer
831 views

Move cursor by percentage

I know that you can go to the Nth % percentage of a file by typing N% in normal mode. Is it possible to advance the line by a given percentage? To clarify, for an example, can I type something to ...
7
votes
2answers
260 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 [ ...
7
votes
2answers
2k views

How can I restore the cursor position when opening a file?

If I edit a file with vim that I have previously edited, I'd like vim to jump to the position I was in when I last closed the file. How can I accomplish this?
7
votes
1answer
912 views

What do matchit.vim's [%, ]%, a% do?

matchit's %/g% are simple enough to use, but I'm having trouble understanding the other mappings, which sound potentially useful but don't seem to work in any understandable way. ]% Go to [count] ...
7
votes
1answer
187 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 ...
6
votes
2answers
516 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 ...
6
votes
2answers
4k 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 ...
6
votes
1answer
144 views

How to keep in the undo history just one change for this command?

I want to keep in the undo history just one change for a long command such as: d0kJx. (I took the command from this answer.) This command (d0kJx) does this (The ^ is the cursor position): Before: a ...
6
votes
2answers
239 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 ...
6
votes
1answer
325 views

How can I advance a page without losing my column position?

I like using Ctrl-f and Ctrl-b to "page-up" and "page-down", but I was wondering if there was a way to do that without losing my current position in a row? For example, I like to work with tab-...
6
votes
1answer
2k 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 ...
6
votes
2answers
200 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: ...
6
votes
1answer
221 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 ...
6
votes
2answers
475 views

Fold/Unfold on moving vertically

Currently my init.vim (neovim's equivalent to the .vimrc) sets the foldmethod to marker: set foldmethod=marker When I open a file all sections are folded and if the curser is placed in the ...
6
votes
1answer
275 views

Indent Lines Up Without Moving

I frequently use the >8j and >8k commands to indent several lines at once. Using j, the lines are indented and my cursor stays at the first line. When I use k, the lines are indented, but my ...
6
votes
2answers
182 views

How can I undo an entire command (e.g. d4b), including the motions?

Say I do d4b, then realize I only needed d3b. If I hit u, it'll only undo the d part, and I'll still be 4 words back as if I just did 4b. I'd like to end up exactly where I was before I executed d4b. ...
6
votes
1answer
230 views

How to move the cursor to the next reference, option, heading in man pages?

If we load the built-in man.vim filetype plugin by writing in our vimrc: runtime ftplugin/man.vim We can read a man page inside a Vim buffer, using the :Man command described in :h :Man: MAN ...
5
votes
4answers
472 views

Move vertically to a specific character on a different line

It is easy to move to a specific character on the same line with t or f. However often it is useful to move to the specific character that is positioned on a different line. Consider this example: ...
5
votes
3answers
2k views

How do I switch around 2 pieces of text?

I have 2 pieces of text, what is a proper way to switch those pieces of text. around e.g. I have this: This is one piece of text. Here is another sentence. And I want to switch around the 3 first ...
5
votes
2answers
1k views

Keep cursor from moving when yanking upwards

I frequently find myself wanting to make a copy of, eg, a function that I just wrote and modify it slightly. In such a situation, I'll generally use something like y5k to copy what I just wrote. I ...
5
votes
1answer
1k 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.['...
5
votes
2answers
217 views

Keystroke to move cursor to the last character of a highlight?

In Visual Mode, you can do this using the o keystroke. However with search highlighting, ie ? or / -- I have a whole selection, but I want to move specifically to the last character of the highlight....
5
votes
2answers
464 views

One-handed Vim utilisation

Today I found myself struggling with Vim while being on the phone. I had only one hand to move around, so the home row was fine but with small hands, every <C-x> shortcuts (<C-d>, <C-u&...
5
votes
1answer
254 views

Is there a % equivalent for editing python code?

When I edit C-style languages, I can use % to jump between pairs of square brackets, braces, and parenthesis. If there an equivalent between for, while, def, if and the last indented line for the ...
5
votes
3answers
563 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 "...
5
votes
2answers
420 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 ...
5
votes
4answers
348 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 ...
5
votes
2answers
120 views

WORD movement across lines

Consider the following text snippet: value1, value2 Now, if the cursor is at (1,1) (the 'v' of value1), W takes me to (2,5) (the 'v' of value2) which is as expected. But if I do dW at the same ...
5
votes
1answer
94 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 ...
5
votes
1answer
162 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\...
5
votes
1answer
164 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 ...
4
votes
3answers
342 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?
4
votes
2answers
234 views

Why after pressing $ in normal mode Vim goes to the last symbol in line, but in visual mode it goes on the /n newline symbol?

Is it possible to change that somehow? Either to make Vim go one symbol further in normal mode, or one symbol less in visual mode?
4
votes
2answers
265 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("$") ...
4
votes
1answer
3k views

How to move cursor in a specific column

I know that there is already a method to move the cursor to a particular line in vim like :25 and it moves to line number 25. But can I configure vim to move to 15th column in 25th line say something ...
4
votes
2answers
790 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 ...
4
votes
2answers
212 views

Jump to a series of line numbers one by one after a stay of x seconds at each line

I have a set of 10 line numbers, n1, n2 ,..., n10 in a code of 1000+ lines. I need to jump from one line to another. My normal practice is to do n1G, n2G... till the set is complete. It takes about 5 ...
4
votes
4answers
1k 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 ...
4
votes
1answer
793 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 ...
4
votes
1answer
137 views

How can I make a down movement at the last line go to the end of the line?

In some editors, if you press ↓ while in the middle of the last line, it takes you to the end of the line (or, equivalently, the document). I have grown somewhat used to this. How do I obtain the same ...
4
votes
2answers
795 views

How to jump to the end of quoted string, considering escaped delimiters

Assuming the following situation $someVar = "Some String with \"escaped\" inner delimiters"; with the cursor somewhere in the double-quote delimited string. What is the quickest way to jump to the ...
4
votes
1answer
450 views

How to resume previous multiple cursors?

I'm using multiple cursors plugin. I'm trying to do the same thing as the second example in their github page. Just trying to add double quote around each of the weekday: mon tue wed thu fri sat ...
4
votes
1answer
304 views

How to move cursor to previous line automatically?

On nano&emacs&any other text editor, when the cursor is at the 1st character of a line (not the 1st line), press the left key and it will automatically jump to the last character of previous ...
4
votes
1answer
62 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 &...