How to prevent Vim scrolling when splitting a window?
I want to stop Vim from scrolling (if that's the right word) when I split a window horizontally.
Let's say I edit a 10 line file in Vim. I have a single window onto the buffer and the window is 40 lines high. There's more than enough room for two windows, one on top of the other, with both showing the whole buffer. And let's say
scrolloff is set to 4.
When I split the window horizontally, the original window is scrolled so that exactly
scrolloff lines are shown between the top of the window and the line the cursor is on -- if there were more than
scrolloff lines between the top of the window and the cursor line -- even though there is no need to scroll.
Put another way, if the cursor is on line 1, 2, 3, 4 or 5 when I split the window, the original window doesn't "move" (good). But if the cursor is on line 6, the window scrolls so that line 2 becomes the top-most visible line...ensuring
scrolloff lines (4) are visible above the cursor line (annoying). Similarly if the cursor is on line 7 when I split the window, the original window scrolls to that line 3 becomes the top-most visible line. And so on.
Is there a way to configure Vim never to scroll the original window when I split it horizontally?
I imagine it's possible to map
<C-W>s to a function which does what I want, but I'd prefer to solve this by configuration if possible.
I've found a solution, borrowing the answer from here.
.vimrc I have:
nnoremap <C-W>s Hmx`` \|:split<CR>`xzt``
And now when I split the window horizontally with
<C-W>s, the original window doesn't scroll at all.
How to stop Vim from scrolling when splitting vertically, I've found a solution, borrowing the answer from here. In my .vimrc I have: nnoremap <C-W>s Hmx`` \|:split<CR>`xzt``. And now when I split the window I want to stop Vim from scrolling (if that's the right word) when I split a window horizontally. Let's say I edit a 10 line file in Vim. I have a single window onto the buffer and the window is 40 lines high. There's more than enough room for two windows, one on top of the other, with both showing the whole buffer. And let's say scrolloff is
As an alternative to Andy Stewart's solution here's what I use in my
(3) (5) ++ +--+ || | | nnoremap _ Hmx``<C-w>szz<C-w><C-p>`x``<C-w><C-p> | || | | | | | +-+-++----+ +--------+ +--------+ (1) (2) (4) (6)
(1) Go top left save mark it to
x and go back to where you were.
(2) Create a new split. Cursor will move to this new split window.
zz to center the cursorline.
(4) Go back to the window you have created the split.
(5) Go back to
x mark and then go back to where you were (to simulate step (1))
(6) Go back to the split you created.
One addition I made is to add
zz onto the newly opened split to make the cursor on the new window easier to catch. My brain can automatically focus onto the center row of the new split.
How to prevent Vim from scrolling buffers when I open split, Somehow on this box every time I split a window ( ^W v or :vs ) the original pane scrolls in such a way that my cursor is exactly scrolloff=5 from the top. I have tried Change the Split Screen Window Size of VIM. There are several shortcuts to change the split screen window size of VIM. You can increase the width of your window by pressing <Ctrl>+<w> and then ‘>’ and decrease the width by pressing <Ctrl>+<w> and then ‘<’. This is how my VIM window looks now.
A recently available option is the stable-windows plugin. I've tried it and it's working well.
How to prevent Vim scrolling when splitting a window, It is really annoying. My guess it tries to keep the cursor in the middle of the screen or something. But even if the both splits end up well above the middle line When you are displaying more than one window, you can set the scrollbind option in each window so they scroll together. In each window that should scroll simultaneously, enter the command: :set scrollbind You can enter scb as an abbreviation for scrollbind, and the ! flag causes :set to toggle a boolean option. Therefore, it is convenient to enter the following to toggle scrollbind on or off:
Vim (text editor): Is there a way to split the screen and then scroll , Google Groups allows you to create and participate in online forums and email-based groups with a rich experience for community vim tips and tricks multiple windows. vertical split :sview file - same as split, but readonly :hide - close current window :only - keep only this window open :ls
Vim: Lock top line of a window - vim - html, Using [code vim]:set scrollbind[/code], you can scroll multiple windows at the same time. Vim (text editor): Is there a way to split the screen and then scroll lock so that one page starts where the How can I shift a block by one space in Vim? For a split window: You can use Ctrl-w + and Ctrl-w - to resize the height of the current window by a single row. For a vsplit window: You can use Ctrl-w > and Ctrl-w < to resize the width of the current window by a single column. Additionally, these key combinations accept a count prefix so that you can change the window size in larger steps.
Keep your cursor centered vertically on the screen, Split your window, decrease the top window height, set the top most line to be the first one and get Is there any way to disable "scrolling below the bottom"? Most of us are Vim users and have tweaked our favorite editor for speed and convenience. See thoughtbot’s dotfiles. One of my favorite tools is the window split. Here is a quick splits overview and configurations to use them more effectively. The basics Create a vertical split using :vsp and horizontal with :sp.