28

The z. and zz commands will recenter the line the cursor is on. z. also moves the cursor to the first non-whitespace character in the line, while zz keeps the cursor where it is. There are similar commands for the top (z<CR>/zt) and bottom (z-/zb) of the window. The versions of these commands that end in a letter keep the cursor column, while the ...


19

To scroll two windows together in vim, need to run :set scrollbind in each of them. As you noted, by default, this only binds vertical scrolling. In the docs for scrollbind, it mentions: The behavior of 'scrollbind' can be modified by the 'scrollopt' option. :help scrollopt reveals that you want to say :set scrollopt+=hor to enable horizontal scrolling. ...


17

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 'scroll' option (default: half a screen). If [count] given, first set 'scroll' option to [count]. Which means that the first time you want to scroll in a ...


13

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 the option scrolloff to always let some lines after your cursor, add this to your .vimrc: set scrolloff=10 For more details see :h 'scrolloff' and :h CTRL-E.


12

As @Doorknob said in his comment, :set mouse=a fixes the problem.


12

As Christian Brabandt suggested in a comment, this can be caused by the 'cursorbind' setting. From :help 'cursorbind': When this option is set, as the cursor in the current window moves other cursorbound windows (windows that also have this option set) move their cursors to the corresponding line and column. You can use :verbose set cursorbind? to ...


8

As suggested by Christian Brabandt in the comments, this was caused by the 'cursorbind' setting. :help 'cursorbind': When this option is set, as the cursor in the current window moves other cursorbound windows (windows that also have this option set) move their cursors to the corresponding line and column. This option is useful for viewing the ...


7

You can use a count before Ctrl-E − 15<C-e> moves down 15 lines. Ctrl-D moves down half a screen by default, although the amount it moves can be configured via the "scroll" option. :help motion.txt will provide this and a whole lot more details.


7

Simply add set nostartofline to your vimrc. See :help 'startofline'.


7

it works for me: set mouse=a map <ScrollWheelUp> u map <ScrollWheelDown> <C-R> But i hope this is just for fun. Must be horrible =)


6

Type zz to center the current line in the screen:


6

See the option termwinscroll as documented at :help terminal-normal and :help termwinscroll. 'termwinscroll' 'twsl' number (default 10000) local to buffer {not in Vi} {not available when compiled without the |+terminal| feature} Number of scrollback lines to keep. When going over this limit the first 10% of the scrollback ...


5

The following works for me: vim log +$ The + bit tells vim to run a command after startup. The $ command moves to the last line in the file. Depending on your shell, you might need \ before the $ was to tell the shell to not treat the $ specially. You can also put it before the file, which makes selecting from command history (e.g. up arrow in your shell) ...


5

That is an issue, that has been often requested but never been implemented. So no, there is no possibility for a better and smoother scrolling, once the lines wrap.


5

Note: I have not tested this with gvim, only with normal vim This piece of code allows me to scroll instead of selecting text when I drag using my mouse. function! MouseScroll() "mark b is the current cursor position "mark a is the previous cursor position norm mb let currPos=line('.') norm `a let prevPos=line('.') if currPos>prevPos ...


5

Your examples work fine for me on Vim 7.4.1689 and Neovim. The following didn't work at first: set mouse=a Then I read the following in :h 'mouse' Enable the use of the mouse. Only works for certain terminals (xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with sysmouse and Linux console with gpm). I use tmux a lot, so $TERM is set ...


5

I would simply use :rightbelow split.


5

Vim doesn't remember where you've been in a file unless you made a change there (see :help changelist) or jumped there (see help jumplist). Also, Vim's cursor is always somewhere in a window, that is, in the part of the buffer visible to the user, so you can't leave the cursor on some line and not have it follow you as you scroll elsewhere in the buffer. ...


4

According to :help scroll-mouse-wheel the answer is no if you are using the Win32 GUI. On the other hand, using X11 GUI or console vim with mouse support, the wheel sends key presses that you can remap. So, you could get the behaviour you describe by :nmap <ScrollWheelUp> h :nmap <ScrollWheelDown> l Note that I'm using nmap for mapping in ...


4

I figured out a way to do that with Hammerspoon and clever usage of mapping. The first part is configuring Shift + ScrollUp and Shift + ScrollDown to scroll horizontally. In order to do that, you have put the following code snippet in your .vimrc: nnoremap <S-ScrollWheelUp> <ScrollWheelLeft> nnoremap <S-2-ScrollWheelUp> <2-...


4

If you are not a member of the clan of arrow keys haters, and if your distribution provider didn't screw up your termcap / terminfo database, the PgUp and PgDown keys should work just fine. And so would Home and End, Insert and Delete, and even the arrow keys, both in insert, normal, select, visual, and Ex modes (and whatever else Vim has in store that I ...


4

Most of the "single key" shortcuts are used for the more important and useful editing operations. Pagers don't have this problem, since they are by definition viewers, so they have all single keys available for buffer presentation. But, in read-only Vim buffers (e.g. when reading a help topic), it may make sense to locally re-assign some of keys. If you ...


4

TL;DR use autocommands, see the end of this post. Here's the result of the investigation I've made: Calling bn call the ex_bnext function which does two things: Go to the desired buffer via the goto_buffer function Execute any command line command passed to the bnext command The goto_buffer function apparently wrap the more generic do_buffer function ...


4

As others have noted, you can prefix both <C-e> and <C-y> with counts, to "expose" that many more lines up or down. Another handy quick scrolling option lets you scroll so that the current line is at the top, middle, or bottom of your screen: z<CR> - scroll so current line is at the top of your screen z. - scroll so current line is in the ...


4

I am used from other editors to use the cursor as a visual bookmark, so that after scrolling by letting the cursor off screen I can come back to its place later. If you're just scrolling through the file and want to bookmark specific place, there's really no way around using Vim's marks. Sorry about that. However, if you want to bookmark a place where you'...


4

You're looking for DrChip's mpage.vim plugin: The mpage.vim plugin supports using multiple windows as separate pages to view a buffer (ie. file), with each window under mpage control sequentially showing lines of text.


4

In addition to setting virtualedit=all, :set nostartofline


4

I was able to solve the first issue using a bit of logic in the mapping so that the j/k is emitted after <c-e>/<c-y> if the current line is the bottom/top line of the window... :nnoremap <expr> <c-j> winline() == winheight(0) ? "\<c-e>j" : "j\<c-e>" :nnoremap <expr> <c-k> winline() == 1 ? "\<c-y>k" : "k\&...


3

Is zz not what you're looking for?


3

Ctrl+e takes count, so the quick and simple way is to create a normal mode mapping like the following: nnoremap <C-e> 10<C-e> This will simply do Ctrl+e 10 times. You can change the number to the number of lines you want it to scroll at once. It's important to note that the mapping is of the noremap type. Otherwise VIm will enter an infinite ...


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