Skip to main content
60 votes
Accepted

Navigation in insert mode

There are many options you have. One option, and IMO the sanest and easiest is to just stop disabling the arrow keys. I understand why many hardcore vimmers say things like You should never ever use ...
DJMcMayhem's user avatar
  • 17.8k
35 votes
Accepted

Trying to move away from arrow keys in normal/insert/visual mode, but small text inserts are killing me!

I believe that the art of Vim has nothing to do with disallowing any tools available for you, but rather finding the best (i.e., most efficient) path to altering text. The truth is that sometimes the ...
Mike Hill's user avatar
  • 716
24 votes

Navigation in insert mode

I like to use the Control key to turn the hjkl movement keys into "universal" movement keys. Here's the relevant bit of my .vimrc: " In insert or command mode, move normally by using Ctrl inoremap &...
Kyle Strand's user avatar
13 votes
Accepted

move forward by a certain number of chars or bytes?

To go to the Nth byte in the file: use :go N, :Ngo, or Ngo (normal mode). To move N bytes ahead, you could use something like this :exe 'go' line2byte(line("."))+col(".")-1+N Unless you have ...
Mass's user avatar
  • 14.2k
12 votes
Accepted

Jump to Next Number

Ctrl+A and Ctrl+X will both jump the cursor to the next number on the line. However, the former will increment the number and the latter will decrement it. You don't want to make any changes, so you ...
Rich's user avatar
  • 32.4k
11 votes

Jump to Next Number

To summarize the comments and make this a full answer: The general search command is shortest: /\d<Enter>. You can then repeat the search with n / N, as usual. To skip to the next full number, ...
Ingo Karkat's user avatar
  • 17.9k
11 votes
Accepted

How to navigate long lines like separate lines?

You can use the gj and gk commands to move the cursor to the character in the next or previous display lines, even when lines wrap. See :help gj and :help gk for details. If you would like to ...
Maxim Kim's user avatar
  • 13.8k
10 votes

Navigation in insert mode

If you just need to modify a small amount of text or a word, you can use <Ctrl-O>h/j/k/l. <Ctrl-O> takes you back to Normal mode just for that command, and then drops you back into insert ...
alpha_989's user avatar
  • 911
10 votes
Accepted

Swap two shortcuts

Yes. You can change just about anything you want to change in Vim. Just do nnoremap <C-f> <C-b> nnoremap <C-b> <C-f> Add those two mappings in your vimrc file and you've ...
Durga Swaroop's user avatar
10 votes
Accepted

Show Outline of Code

This is possible with Tagbar plugin, which use ctags to generate the tags. Used in collaboration with Universal Ctags, it supports various langages.
fievel's user avatar
  • 413
9 votes
Accepted

Brace { } navigation without opening folds

Thanks to @romainl for this answer on super user. I couldn't have written this without their help! You can use the foldopen option to determine which set of motions will or won't open a fold. From :h ...
DJMcMayhem's user avatar
  • 17.8k
9 votes

Trying to move away from arrow keys in normal/insert/visual mode, but small text inserts are killing me!

My solution is to use everything vim offers me: HJKL, /, FftT, {n}w/b/e, ^, $, %, [], ][, [{, and also arrow keys, control arrow keys, home, end, Pg Up and Down, the mouse... Arrow keys and hjkl are ...
Luc Hermitte's user avatar
  • 17.7k
7 votes
Accepted

How to show the current location in a yaml hierarchy

The right way to do it would be to use an external program if the markup language presents a complex structure or particular edge cases, like the bunch of tools you can find for JSON. Though YAML ...
LEI's user avatar
  • 1,636
7 votes
Accepted

Go forward to first alphabetic character

Based on DLMcMMayhem's hint, I found that following search will do what you need: /\A*\zs\a \A* searches for zero or more non-alphabetic characters (equivalent to [^A-Za-z]) \a searches for any ...
jpaugh's user avatar
  • 284
7 votes
Accepted

How do I jump to the next line with the same indent level?

I think that some plugins might do what you want: they create text objects based on the indentation and then let you navigate between these text objects. But installing a plugin just for that is not ...
statox's user avatar
  • 50.4k
7 votes

Navigation in insert mode

Hit esc then use hjkl and wWbB and any other navigations you would like to make. The whole point of hard mode is to get you to learn to navigate with more complex vim motions. Make small edits then ...
Archangel33's user avatar
7 votes

List of buffers in view pane

You can use GVim on Windows so Vim is not really a valid reason for switching to Linux. You can display a list of buffers with :ls. For the last time: Read The Fantastic Manual.
romainl's user avatar
  • 41.8k
7 votes

How to jump to the previous location in the same file?

FYI I wrote this before the question was updated to make it clear that OP wants to jump to the previous location repeatedly. Given that this answer still addresses the question asked in the subject ...
B Layer's user avatar
  • 20k
7 votes
Accepted

Moving up and down wrapped lines

You can move up and down between the "display lines" of a wrapped line with the gj and gk normal mode commands. If you find this unintuitive, a fairly common mapping is to swap these with ...
Rich's user avatar
  • 32.4k
7 votes
Accepted

Improve `gf` such that it would jump to the exact line, if possible

What you want already exists: :help gF. Note that gF behaves like gf in the absence of a line number so you can default to gF if you don't want to think too much about which command to use in which ...
romainl's user avatar
  • 41.8k
6 votes

List of buffers in view pane

I would also add that in gVim you can get a very close approximation to this feature. If you click on the buffers menu item and then click the "tear off" (--✂-----) button. It opens up a little window ...
Tumbler41's user avatar
  • 7,776
6 votes
Accepted

moving through the doc, caret staying centered

You're looking for :h 'scrolloff': 'scrolloff' 'so' number (default 0) global Minimal number of screen lines to keep above and below the cursor. So you can add something like ...
statox's user avatar
  • 50.4k
6 votes

Why isn't this implemented by default in vim? (line by line Scroll)

*CTRL-D* CTRL-D Scroll window Downwards in the buffer. The number of lines comes from the 'scroll' option (default: half a screen). <b>If [count] given, first ...
dedowsdi's user avatar
  • 6,318
6 votes

Trying to move away from arrow keys in normal/insert/visual mode, but small text inserts are killing me!

In general I try to stay out of insert mode as much as is humanly possible. (A fact I alluded to in the comments.) Most of the time, for lots of small edits I make to nearby lines, I will endeavour to ...
Rich's user avatar
  • 32.4k
6 votes

How can I find the function name while navigating code?

The simplest solution is to find the first unindented line that starts with a letter (by the way, this is exactly what diff -p does). I'm sure I borrowed this trick somewhere, but I can't remember the ...
Matt's user avatar
  • 21.3k
5 votes

Navigate to tag in a new tab if not already opened, like `tab drop`?

Put this in your vimrc: map <C-]> :TabExpand 1<CR> command -nargs=1 TabExpand call HandleTabTagExpand( <f-args> ) let s:commentchar = """ function HandleTabTagExpand(tagnumber) ...
Tim's user avatar
  • 436
5 votes
Accepted

How to jump to the previous location in the same file?

The built-in jump-motions do not differentiate betweeen buffer-local and "remote" jumps, they just move along the jumplist. You need a custom solution that parses and filters the jumplist. My ...
Ingo Karkat's user avatar
  • 17.9k
5 votes
Accepted

Fastest way to navigate various points in vim

I'd like to primarily challenge the premise of your question/challenge/race: What would be the fastest that someone could get to those four locations in vim? When you're editing text, you're not ...
filbranden's user avatar
  • 29.6k
5 votes
Accepted

How can I make zz not center cursor when approaching end of file?

If you're willing to bring a function into the mix I whipped this up... func! ModifiedZZ() " modify to your liking let l:max_pad_lines = 10 norm! zz let l:to_scr_end = winheight(...
B Layer's user avatar
  • 20k
5 votes
Accepted

Skip to next batch of search results (or find next non-match)?

I was trying to come up with something fairly short and found this novel approach (novel to me anyways...I'd never tried it before). There is an inverse counterpart to :g (global command): :v. This ...
B Layer's user avatar
  • 20k

Only top scored, non community-wiki answers of a minimum length are eligible