33

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) ...


10

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> ...


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 ...


8

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

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 ...


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

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

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

*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 &...


5

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


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

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.


5

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.


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'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


4

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-...


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

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

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.


3

You can use the regex: nnoremap <silent> <leader>gt ?^\n\{2,}<CR> nnoremap <silent> <leader>gb /^\n\{2,}<CR> Find more with :help regex


3

I found myself that it is :set display=lastline (where @@@ at the end of the last line indicates that line is unfinished), or :set display=truncate (where @@@, starting on a new line, displayed as the last line, indicates the same). To quote :help 'display': 'display' 'dy' string (default "", set to "truncate" in |...


3

Has vim built-in functions which can return a list of tab files? like :tabs command You'll have to do some parsing, but you can use let myVar = execute('tabs') for this. How to get tag's filename under the cursor? I don't think there's a built in way to do this but here's a quick and dirty first stab at a function that will do it: function! ...


3

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 ...


3

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 ...


3

Yes. There's w (mnemonic: word) which moves to the beginning of the next word, and b (backward) which moves to the beginning of the previous word. Then there's e which moves to the end of the next word, and ge which moves to the end of the previous word. You can change which characters are considered part of a word using the iskeyword option, and many ...


3

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 ...


3

You could write a dirty function for doing this for you: au BufNewFile * nested call ReadFile() func! ReadFile() let l:filename = expand('%:p') if l:filename =~ ':\d\+$' let l:number = matchstr(l:filename, ':\zs\d\+$') let l:filename = matchstr(l:filename, '^[^:]*') execute 'bd | e! '. l:filename call cursor(l:number, 1) endif endf ...


3

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 EnhancedJumps plugin extends the built-in <C-I> / <C-O> commands with variants that move only within the current buffer (this is what you're asking for), ...


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