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) ...
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>
Yes. You can change just about anything you want to change in Vim.
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 ...
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' string (default: "block,hor,mark,percent,quickfix,
Based on DLMcMMayhem's hint, I found that following search will do what you need:
\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 ...
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 ...
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 ...
Put this in your vimrc:
map <C-]> :TabExpand 1<CR>
command -nargs=1 TabExpand call HandleTabTagExpand( <f-args> )
let s:commentchar = """
let tagident = expand("<cword>")
sil exe "tselect ".tagident
catch /^Vim(\a\+):E433:/ " no tag file
echom "No ...
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.
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 ...
You're looking for :h 'scrolloff':
'scrolloff' 'so' number (default 0)
Minimal number of screen lines to keep above and below the cursor.
So you can add something like this in your .vimrc:
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 ...
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.
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 ...
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 ...
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 ...
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
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:
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 ...
You could write a dirty function for doing this for you:
au BufNewFile * nested call 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)
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), ...
It dawned on me that why do I not move page down and further scroll two lines, and same can be said on page up.
" Scroll a page with no repeated lines,
" while default shows two lines in both present and next window
nnoremap <C-f> <C-f><C-e><C-e>
nnoremap <C-b> <C-b><C-y><C-y>
I am finding myself on the right ...
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 ...
I'm using the yaml plugin by Meijvogel and that has a YamlDisplayFullPath function which he recommends putting into autodisplay mode though I prefer it on InsertLeave like so:
autocmd! InsertLeave *.yml YamlDisplayFullPath
You can do it like this:
let stop_re = 'sql\%(Keyword\|Operator\|Statement\)'
while search('\<', 'W'.a:forward)
if synIDattr(synID(line("."), col("."), 1), "name") =~ stop_re
There is a pretty quick and dirty way using \%'a:
for c in map(range(char2nr('a'), char2nr('z')), 'nr2char(v:val)')
call matchadd('Search', '^.*\%'."'".c.'.*$')
Replace Search with an appropriate highlighting group. You can also replace the map(range(...)) with any set of marks you want, e.g., ['A', 'B'].
A few caveats:
Only highlights behind ...