73
votes
Accepted
Why is using arrow keys in normal mode considered bad practice?
Actually this is not a bad practice.
A lot of people (including Vim's doc as @B Layer's answer shows) argue that you shall not use arrow keys because it makes your hands move from the home row (the ...
49
votes
How to disable arrow keys in vim?
In case you, or someone else reading this topic, just wants to disable the key movements without the text warning enter the following lines in .vimrc
noremap <Up> <Nop>
noremap <Down&...
42
votes
Accepted
Delete until the right end of the current inner block
I would use
d])
which means delete (d) to the next unmatched ')' (])).
See :help ]).
41
votes
Why is using arrow keys in normal mode considered bad practice?
I don't know if this is really relevant any more, but I'm an old-timer so here's a bit of history.
In the old days, VT100 terminals had arrow keys, but pressing one transmitted an escape sequence ...
38
votes
Accepted
How to delete line above/below cursor, but not current line?
:-d
cuts the line above the current line.
:-5d
cuts the 5th line above the current line (but moves the cursor).
:-5,-d
cuts the 5 lines above the current line.
:+,+5d
cuts the 5 lines below the ...
32
votes
Accepted
How to disable arrow keys in vim?
You can install the hardmode plugin and in your .vimrc put in
let g:HardMode_level = 'wannabe'
let g:HardMode_hardmodeMsg = 'Don''t use this!'
autocmd VimEnter,BufNewFile,BufReadPost * silent! call ...
32
votes
Accepted
Scroll a quarter (25%) of the screen up or down
Maybe ctrld and ctrlu could be what you are looking for. By default they move half of the screen.
From :h CTRL-D:
Scroll window Downwards in the buffer. The number of
lines comes from the '...
31
votes
Accepted
How to restore the position of the cursor after executing a normal command?
You should use getpos():
To save you position in a variable:
let save_pos = getpos(".")
getpos() takes as argument a mark, here "." represents the current position of your cursor.
And to restore ...
31
votes
Accepted
How to replace inner text with yanked text
You can use vi"p when inside "". This can replace text in yank register, so it matters when you want to use original yanked text more than once.
EDIT:
Additional info from Octaviour comment regarding ...
30
votes
Why is using arrow keys in normal mode considered bad practice?
While I agree with @statox that no one should be chastised, shunned, excommunicated, or tarred-and-feathered if they choose to use the arrow keys...use your software however you see fit...I wouldn't ...
26
votes
Accepted
How do I make Vim always display several lines after EOF?
You can use ctrlE to scroll down your file, when you are at the end of the file it will add "virtual" line so the last line of the file is not at the bottom of the windows.
Additionally you can use ...
26
votes
Accepted
Go to column number?
Just type 80| -> :h |
This is perfect for interactive mode. When scripting, there are other ways.
23
votes
Accepted
How to go to end/get out of the parenthesis of a line in vim?
I'm not 100% clear if this is what you're asking, but I think you might be looking for:
])
This jumps to the nearest enclosing ). So if your cursor was on the / in the below:
(2 / (3 + 5) * 9)
^...
22
votes
Accepted
How to quickly add content in a new line at end of file?
If file is already opened in normal mode
Use:
Go
G goes to the end of the file
o enters insert mode on a line below the current one
If you are opening the file from the command line
You can open ...
20
votes
Accepted
Vim HardMode Fine Grain Movements
These are just a few of the movements that vim is capable of, these should get you going for now.
TL;DR
Use Vim's built in help feature on navigation or better still usr_03.txt
Search google for vim ...
18
votes
After copying a visual selection, return to original location
A possible solution is to use jumps:
Before yanking or visually selecting you can set a new jump which you'll be able to access after your cursor has moved. To do so use m`.
Then after your cursor ...
17
votes
Accepted
What is the difference between j, CTRL-J, <NL> and CTRL-N in normal mode?
Interesting that you mentioned <CR>. <CR> or carriage return, technically used to mean go to the start of the line. <NL>, or newline aka line feed (usually called LF), was used to ...
17
votes
Accepted
How do I get back to the previous line after moving?
Use `` to jump back to the exact position you were in before you searched/jumped, or '' to jump back to the start of the line you were on before you searched/jumped.
You can also use CTRL+O and CTRL+...
16
votes
Why is using arrow keys in normal mode considered bad practice?
Other answers have said that the efficiency loss from moving your hands from the home row isn't that big a deal, and I mostly agree. However, what is a big deal is when you are learning vim, always ...
15
votes
Moving to an outer block
[% and ]% provided by matchit or match-up
The answer by Mass suggesting [{ and ]} works perfectly for unmatched curly brackets but only for curly brackets. This should be considered as an advantage. ...
14
votes
After copying a visual selection, return to original location
You can avoid moving the cursor with:
:'{,'}y
See :help range, :help mark-motions, and :help :y.
14
votes
Accepted
Move inside next quotes?
f" jumps to the next quote, and F" jumps to the previous one. 3f" jumps three more quotes, and so on. This seems enough to me. If the cursor is inside the quote, and you want to jump to the position ...
13
votes
How to delete till the end of the previous line (i.e. to end of line above)?
Well, you can combine the "backward search" motion and the delete operator:
d?$<Enter>
13
votes
Accepted
How to delete till the end of the previous line (i.e. to end of line above)?
Try d0kJx
Deletes backwards to the beginning of the line, moves up, then joins the two lines and then removes the space in between the two joined lines.
You don't have to leave normal mode with this....
13
votes
Accepted
Why does >3k move the cursor up when >3j does not move it down?
Yes, Vim automatically moves to the top most indented line. To see this, position the cursor in the middle of a paragraph and use >ap to indent the whole paragraph.
Note that this is not specific ...
12
votes
How do I jump to the location of my last edit?
Saving a character on the accepted answer:
gi
Will take the cursor to the exact point last edited and put you in insert mode, ready to continue typing. (It's also quicker to type!)
12
votes
Accepted
Mapping with motion
vim supports operator-mapping :h map-operator.
What you need is an operatorfunc, and a mapping. for your needs, the followings codes work. Well it is just an example, you refine further.
nmap <...
12
votes
Accepted
How to move cursor in a specific column
If you want to do it from the normal mode, just type: 15|. If you want to move to 15th column in 25th, type 25G15|. If you want to do it as a command you can type: :call cursor(25,15) but I think it ...
12
votes
Accepted
Tag navigation using CTRL+] does not work with Non English keyboard on Windows
Say hello to knowledge fragmentation: https://stackoverflow.com/q/6932702/520162 This question was already asked and answered on StackOverflow.
The key is to press CTRL and the key that is located ...
12
votes
After copying a visual selection, return to original location
My cursor is in the middle of a paragraph
If you've just edited it, the simplest solution is to type g ; which will position your cursor on the last edit position.
And if you haven't edited the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
cursor-movement × 296key-bindings × 44
cursor-motions × 42
normal-mode × 24
vimscript × 21
cursor × 16
search × 14
vimrc × 12
insert-mode × 12
scrolling × 12
cut-copy-paste × 11
indentation × 9
autocmd × 6
visual-mode × 6
jumplist × 6
substitute × 5
find × 5
count × 5
neovim × 4
gvim × 4
macro × 4
wrapping × 4
navigation × 4
whitespace × 4
mark × 4