37

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 the arrow keys again! Every time you use the arrow keys, you waste 3 minutes of time, a puppy dies and somebody switches to Emacs! (Obviously I'm kidding) ...


32

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 arrow keys really are the most efficient. This is particularly true in cases where several small insert-mode changes need to be made that are interspersed with ...


14

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 <C-h> <Left> inoremap <C-j> <Down> inoremap <C-k> <Up> inoremap <C-l> <Right> cnoremap <C-h> <Left> ...


9

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 both as inefficient when moving around. If the need is only to move of a couples of characters or lines, they are perfect. For more, Vim has better solutions. ...


8

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 both of those commands swapped. nnoremap - Maps new key combinations to existing commands without affecting any other commands that might be using the original ...


7

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 alphabetic character (equivalent to [A-Za-z]) \zs is a zero-width match (i.e. matches nothing) but tells the regex engine to reset the start of the match to the ...


7

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 'foldopen' *'foldopen'* *'fdo'* 'foldopen' 'fdo' string (default: "block,hor,mark,percent,quickfix, ...


7

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, not the next digit, use /\d\+ instead. If you don't want to clobber your search pattern, you can use the lower-level search() function. As this is a lot to ...


6

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 or tools you can find for JSON. Though YAML seems to be pretty straightforward Even if YAML seems to be pretty complex, I started with a one liner working on your snippet to end up with this Vim script you ...


6

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 have the following options to quickly jump to the next number on the line. Ctrl+ACtrl+X Ctrl+XCtrl+A Ctrl+Au Ctrl+Xu


6

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 that shows you all your buffers and does pretty much what you want. You can also do this with :tearoff Buffers. I.E.


6

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.


6

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 line and has been upvoted a bit I think it's worth leaving here. Cheers. Generally speaking, marks are used to jump to previously visited locations in the ...


6

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 this in your .vimrc: set scrolloff=10


6

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 navigate those display lines using j and k, you can remap them in your .vimrc: nnoremap j gj nnoremap k gk Beware that these remappings have side effects, for ...


6

*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 set 'scroll' option to [count].</b> ... Execute 1<ctrl-d> for one time, it will set 'scroll' to 1, you can then use <c-d> and &...


6

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 enter insert mode only once. For your given example of changing getVal to get_val on two consecutive lines with the cursor starting far from the first edit ...


5

Put this in your vimrc: map <C-]> :TabExpand 1<CR> command -nargs=1 TabExpand call HandleTabTagExpand( <f-args> ) let s:commentchar = """ function HandleTabTagExpand(tagnumber) let tagident = expand("<cword>") redir @a try sil exe "tselect ".tagident catch /^Vim(\a\+):E433:/ " no tag file echom "No ...


5

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 mode, so it saves you some amount of key presses, if you need to go into normal mode for a small movement. Ref: 1. http://vim.wikia.com/wiki/Use_Ctrl-...


5

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 changed virtualedit, you can move forward with <space>. To go to the Nth character in the file, use 1goN<space> in normal mode. To move ahead N ...


5

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 the regular j and k commands: nnoremap j gj nnoremap k gk nnoremap gj j nnoremap gk k


4

This is possible with Tagbar plugin, which use ctags to generate the tags. Used in collaboration with Universal Ctags, it supports various langages.


4

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 always the best solution: you could do it by youself with a bit of vimscript to add to your vimrc: First let's create a function which loops on the lines of ...


4

If you want to move more than ONE or TWO positions... ...the best choice is to hit ESC, move around, and get back to insert mode again. There's no point on create mappings like <C-h> to move left and then start hitting it too many times... as a vim user you're not supposed to hit the same key multiple times to achieve a smart movement. (If the ESC key ...


4

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 move to a new location, using normal mode. If you wan't to learn how to navigate faster with hardmode enabled, check out my answer from another question on the ...


4

With :n you are going through the argument list. You can use :args to see where you are in the current argument list. You can use :first to start at the beginning and use :last to go to the last argument. You can also use :previous to go to the previous argument. To add files to the argument list you can use the :argadd and argedit command. And finally if ...


4

You can also use CTRL-e and CTRL-y to move the view, while not moving the cursor. At the end of your file, you can use CTRL-e until the last line of the document is at the first line of the page.


4

Tab navigation is one dimensional, so it has commands which mirror similar commands, :bn, :cp, etc. Window navigation is two dimensional, so it has commands that align with the two dimensional normal mode motions, hjkl. It should also be noted, in addition to the commands you listed, there are also both normal mode tab navigation commands: gt, gT, and ...


4

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 only moving to specific locations on the text, you're moving to those points and adding or modifying text there, before moving on to the next location and ...


4

Most likely the developer didn't feel that this feature is important enough to deserve a simple key. On the other hand it is possible to create mappings using 1<C-d> and 1<C-u> when you need it. Remember that vi was initially implemented by Billy Joy in 1976. At that time scrolling the screen might have been an expensive operation.


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