Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

0
votes
2answers
39 views

Why does `:m+1` not move two lines down when `:m-2` moves one line up?

In the help for move: :[range]m[ove] {address} *:m* *:mo* *:move* *E134* Move the lines given by [range] to below the line given ...
1
vote
1answer
11 views

How to make comma and semi-colon direction-insensitive of the latest f,F,t,T command

I can customize the n and N keys to always search backward and forward respectively irrespective of what the last search direction was with the following commands: nnoremap <expr> n (v:...
0
votes
1answer
29 views

How to replace a word with spaces

Suppose I have the following text: This is a test of the emergency broadcast system What I want to do is delete the word "test" and replace it with four spaces: This is a of the emergency ...
5
votes
2answers
111 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 ...
0
votes
2answers
41 views

How to get PageUp and PageDown to return to the exact same character?

Because the default Ctrl-B/F or PageUp/Down behaviour usually leaves the cursor somewhere other than where it started, I remapped PageUp and PageDown in my .vimrc to simply move up/down 25 lines. ...
3
votes
1answer
39 views

How to scroll two vertical splits at the same time?

I am not sure if it is even possible but, when I am working with vertical splits, sometimes, I want both of them to scroll up/down at the same time rather than using this combination: scroll down ...
-1
votes
1answer
27 views

how to move to the end of a string / beginning of string for a macro

i want to write a makro and need to know how i can move to the end and to the beginning of a string, respektively i want to visually select the link so that i can surround it with brackets. my line ...
1
vote
1answer
73 views

Keep relative cursor position after indenting with >>

Can I setup >> to keep the relative cursor position? For example, assuming the line is def fun(<cursor>): can I make >> result in def fun(<cursor>): ? Obviously, with ...
1
vote
1answer
38 views

How to get w word and b back to treat hyphens and underscores like spaces?

I currently have this in my vimrc set iskeyword+=- But when I press w or b my cursor skips over hyphens. Am I misunderstanding iskeyword? How do I get word and back commands to treat hyphens (and ...
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 ...
1
vote
0answers
62 views

I want to improve my cursor movement [closed]

The thing that slows me down the most when using VIM is getting my cursor to where I want it to be. How should I practise improving this? Are there tools that teach you movement tricks and force you ...
1
vote
1answer
44 views

Is there any `setvirtcol()`?

I'm looking for a way to precisely set the cursor position given a virtual column. Is there only :exe "normal! ".vcol."|"? NB: I need virtual columns as they're the only thing that I'm able to ...
4
votes
1answer
117 views

How to jump to a character offset in a buffer?

Vim has the command :goto to go to a byte offset in a buffer. Is there an equivalent for a character offset? If not, is there a better way to implement it than repeatedly testing the cursor's ...
2
votes
1answer
87 views

What is the difference between ^ and _ for cursor movement

They both seem to move the cursor to the first non-blank character of the current line and I wonder what was the reason for duplicating this functionality
1
vote
1answer
28 views

How to show cursor in the middle of the window despite being at the end of the file?

I am editing at the bottom of a file, but I want the line I'm editing to appear in the middle of the screen. Is this possible without adding a bunch of spurious newlines at the end of the file?
2
votes
1answer
47 views

In visual mode, how can I select to either the next section or the end of the file?

I'm having trouble selecting sections in a file in a visual mode macro to separately perform some action on each section. Here's an example file: [insert introduction here] ... .... ------ section .....
3
votes
2answers
49 views

cmake movement plugin

I'm wondering, if there's a way to move with % in CMakeLists.txt files between foreach and endforeach, if and endif, function and endfunction, … googeling I only found plugins that allow calling ...
2
votes
2answers
103 views

why ctrl-h and ctrl-l behaves differently in normal mode?

In normal mode, I tried CTRL-H and CTRL-L, and I found that the former worked while the latter didn't do anything at all. I wonder why their behaviors are not the same?
0
votes
2answers
135 views

Why is Vim pasting after the cursor?

I don't understand why is Vim pasting after the cursor; for example in this example (where the cursor is at the start): |The quick brown fox jumps over a lazy dog ^ I would like to exchange fox and ...
2
votes
3answers
425 views

Moving to an outer block

Does anybody know the command for moving to an outer block of brackets/parentheses? Lets say that my cursor is in the innermost bracket. I know that % moves to a matching bracket, but is there a ...
2
votes
1answer
50 views

change inner backslashed quotes

I know the ci" motion and others :changes, but I need something like a ci\" in order to change inner a backslashed quotes. Assuming * as the cursor position: a = "message says: \"fo*o bar\"" I would ...
0
votes
1answer
24 views

Template plugin(?) to jump to next occurance of '<++>'

I just noticed that my current box with vim is missing a crucial feature, but I am unable to bring it back. A long time ago I had a vim setup where I could press Ctrl+J (IIRC) and then my cursor ...
1
vote
2answers
69 views

How to remove a line and paste it at the beginning of a range

How to remove a line and paste it at the beginning of a range? line 1 line 2 line 3 line 4 xxxxxxxx For example, here I want to remove the 5th line and paste it before the first two lines, to change ...
1
vote
2answers
44 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} ...
0
votes
1answer
53 views

`0` only moving to first “visible” column

I have a strange trouble with vim (8.0.95). My format options are fo=cq and nowrap. When I have a long line, which does not fit my terminal window, the view of the file does not include the first ...
0
votes
1answer
69 views

Jump to next semicolun

I can use fd to jump to the next d character. How can I jump to the next semicolun? f; doesn't seem to work. Also, for other special symbols. Thanks
43
votes
8answers
15k views

Why is using arrow keys in normal mode considered bad practice?

I have read it in many articles (e.g.) that it's a bad practice to use arrow keys in normal mode. Could somebody explain why is it considered a wrong practice, if at all?
3
votes
2answers
384 views

Why does “e” move you one character before the actual end of the word?

Maybe it was discussed many times (I strongly believe), but I could not formulate my question properly. So lets imagine we have this sequence of words: foo bar baz Applying 3e will move us onto: ...
1
vote
2answers
117 views

How to enable disabled movement keys in netrw?

Recently I started using and learning Vim. I turned off movement keys in my .vimrc file like this: noremap <Up> <NOP> noremap <Down> <NOP> noremap <Left> <NOP> ...
3
votes
2answers
154 views

How do I make Vim preserve column position when moving between lines?

I'm using one of Vim distribution called SpaceVim and everything is good enough except some details. How do I make spacevim to preserve column position when moving between lines? For instance - move ...
0
votes
2answers
138 views

How to make f{char} case insensitive?

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
68 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} ...
7
votes
2answers
2k 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 ...
1
vote
1answer
183 views

Make ctrl-j and ctrl-k work like they do in less?

I would like to use ctrl-k and ctrl-j to not only move the cursor up or down (by lines), but also to scroll the portion of the document that is visible. Effectively, leave the cursor where it is and ...
2
votes
2answers
189 views

Move to the first/last non-whitespace character of the column (“vertical W/B/E”)

For instance move from (the cursor is on the letter in bold italic, in the second column) blablabla blablabla blablabla blablabla bla bla bla bLablabla l@st to blablabla blablabla blablabla ...
4
votes
1answer
54 views

Why does gUw keep cursor in same position but gUb moves it to the start of the word?

For example: if my cursor is on c in abcde and I do gUw then the result is abCDE with the cursor on C, while gUb results in ABcde with the cursor on A. Is this the expected behaviour? It seems that ...
2
votes
0answers
129 views

Relative line number colouring

I have relative numbering turned on. There's no immediate way of telling which direction I want to move, however. For example, sometimes I see line number "7" and move 7j (7 lines down) when I really ...
3
votes
2answers
100 views

Replace text and move cursor to end of replacement in insert mode

How can I perform a search-and-replace and leave the cursor at the end of the replacement? I want to replace $...$ with \(...\) as I type in insert mode. Notice that I can't use an abbreviation, ...
2
votes
2answers
411 views

Move cursor to new line character

When in visual mode you can select the new line character. E.g.: The quick brown fox jumps over the lazy dog.⏎ In visual mode you can select both the period and the (invisible) carriage return, or ...
0
votes
0answers
33 views

Prevent viewport from jumping to the right

As soon as I put the cursor on column 79 or beyond, the Vim viewport jumps to make sure the cursor is put in the middle of the viewport. I find it massively disturbing, but could not navigate my way ...
1
vote
2answers
64 views

How do I prepend text preserving camelcase

A common process for me is to have a camelCased word that I wish to prepend to. I find the vanilla method a little too cumbersome as I will describe below. What I'm wondering is if there is a better ...
4
votes
1answer
225 views

How can a mapping have behavior dependent on the presence of a count?

I have this mapping to move by visible line when wrap is enabled nnoremap <silent> j gj nnoremap <silent> k gk But when I use a count (like 10 j), I expect to move by actual lines How ...
1
vote
2answers
302 views

How to move to same indentation as previous line

Suppose I have many lines of various indentations. E.g. qqqq wwwwwwww eeeeee rrrrrrr tttttt yyyyyyy If I am anywhere on the fourth line above which is blank. Is there a ...
4
votes
1answer
101 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 ...
8
votes
1answer
598 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] ...
0
votes
1answer
185 views

Removing trailing spaces with the substitute command changes the cursor position

From http://vim.wikia.com/wiki/Remove_unwanted_spaces function TrimWhiteSpace() %s/\s\+$//e endfunction autocmd FileWritePre * call TrimWhiteSpace() autocmd FileAppendPre * call TrimWhiteSpace() ...
4
votes
2answers
3k views

Go to column number?

I often use something like :80 to quickly go to a line (80 for example). I'm in a unique situation where I want to go to column 80, to see if lines are too long in files. Any quick way to do this in ...
6
votes
2answers
108 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. ...
1
vote
0answers
115 views

Jump from tag-to-tag in xml?

I'm using emmet-vim which says that it can work in xml files but I can't seem to navigate between tags. Say I have this structure: <dependency> <groupId>com.google</groupId> &...
2
votes
1answer
73 views

Move cursor after yank according to direction

I want to use yt<anyChar> for yanking and for jumping, so that cursor moves to the first char before <anyChar>. For backward moving this is working by default (after yT<anyChar> ...