Questions tagged [cursor-movement]

Moving the cursor another place in the buffer.

Filter by
Sorted by
Tagged with
1
vote
2answers
100 views

How to move a cursor to the last line with auto indent?

Assume autoindent is set, and you have the buffer below. Note the cursor is represented as I. for i in range(1, 6): print(i)I When you hit Enter key, you get this. for i in range(1, 6): ...
0
votes
2answers
63 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 ...
2
votes
1answer
20 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:...
1
vote
1answer
515 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
323 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
116 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 ...
1
vote
2answers
219 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. ...
10
votes
2answers
9k 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 ...
1
vote
2answers
221 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> ...
2
votes
1answer
58 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 ...
22
votes
1answer
2k views

How to make movements respect camelCase or snake_case?

It is common to use either camelCase or snake_case to separate multiple words which form an identifier. It would be nice if the "word" movements (b, w, e) would detect those inner-identifier ...
2
votes
1answer
127 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 ...
5
votes
2answers
701 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 ...
-1
votes
1answer
34 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 ...
31
votes
8answers
2k views

How do I move vertically until reaching a non-whitespace character?

In a very long file with (accurately-) indented code, it may be helpful to move directly to a line of text above or below the cursor which delimits the indenting. (One way of doing this could be via ...
2
votes
2answers
301 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?
2
votes
1answer
234 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 ...
3
votes
1answer
98 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
75 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
80 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 ...
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
3answers
2k views

Control - Arrow to Skip Over Text

I am new to Vim, however I am learning to love it. As a former/current Windows user, there is one shortcut that I depend on and would like to configure in Vim. On windows I can use ctrl-arrow left ...
3
votes
1answer
253 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
96 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
30 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
52 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
78 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 ...
1
vote
0answers
183 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> &...
29
votes
3answers
1k views

Why can ci" be outside of quoted area and ci( only works inside parentheses?

When using ci" the cursor does not have to reside in the double quoted area. |String somestring = "some text"; Assuming the pipe is the cursor position, ci" will make it jump to the quoted area. ...
0
votes
2answers
263 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 ...
0
votes
1answer
28 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
52 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} ...
19
votes
3answers
947 views

How can I get ‘n’ to go forward even if I started searching with ‘?’ or ‘#’?

Vim has (at least) two sets of commands that search in opposite directions. Typing / and then a pattern will search forward through the document for the pattern; typing ? and then a pattern will ...
8
votes
2answers
252 views

What does [count]% do?

I would expect [count]% to jump back and forth between matching braces count times or something like that, but instead, typing that command seems to move the cursor to a random place in the buffer. ...
1
vote
2answers
82 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 ...
16
votes
4answers
6k 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 ...
26
votes
1answer
12k views

How can I jump to the next “paragraph”?

Right now I'm working with some blocks of text that are over 1000 lines long. Is there a simple way to move to the beginning of the next paragraph? My workaround for now is searching for two ...
0
votes
1answer
78 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 ...
6
votes
2answers
305 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 ...
0
votes
2answers
360 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} ...
0
votes
1answer
74 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
44
votes
8answers
16k 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?
6
votes
2answers
4k 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 ...
4
votes
2answers
225 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 ...
2
votes
2answers
415 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: ...
11
votes
6answers
7k views

How to delete line above/below cursor, but not current line?

Is there a command for deleting line (or n lines) above current one? Above = current not included. I.e., is there an alternative to dk which doesn't delete current line? Similar to how o/O and p/P ...
1
vote
2answers
73 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} ...
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 ...
7
votes
2answers
5k 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 ...