I am using vim 7.4 under Ubuntu Linux.
When I split window by using ":sp hello.c",
if I click the upper window, then the mouse wheel scrolls the upper window.
But if I click the lower window, then depending on which part of the lower window I click, it scrolls either the upper window or the lower window.
Specifically, if I click inside the upper half of the lower window, it scrolls the upper window; if I click inside the lower half of the lower window, it scrolls the lower window.
How can I make it work correctly?
Thanks.
Here is my setting:
ambiwidth=double helplang=ko nomodeline ruler syntax=php ttymouse=xterm2
filetype=php history=50 mouse=a scroll=25 ttyfast
backspace=indent,eol,start
fileencoding=utf-8
fileencodings=ucs-bom,utf-8,default,latin1
printoptions=paper:a4
runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vi
m/addons/after,~/.vim/after
suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
I was able to get around this problem, by adding the following lines to my .vimrc file:
noremap <ScrollWheelUp> 4<C-Y>
noremap <ScrollWheelDown> 4<C-E>
noremap <S-ScrollWheelUp> <C-B>
noremap <S-ScrollWheelDown> <C-F>
from the following document:
https://superuser.com/questions/351972/how-can-i-change-the-scroll-wheel-behavior-in-vim-so-that-it-scrolls-instead-of
Related
iTerm2 has a very nice feature that allows, when scrolling the mouse, to move the cursor up and down.
However, if I enable the mouse in vim with :set mouse=a, the scrolling behavior changes: it now scrolls the file but does not move the cursor until the cursor gets out of view.
Is there a way to keep the iTerm2 scrolling along with mouse enabled in vim?
Does this help?
map <ScrollWheelDown> j
map <ScrollWheelUp> k
Have a look at :help scroll-mouse-wheel.
I.e. is it possible in vim to edit large file in several simultaneously opened tabs in the following way: first part of text (that fill all vertical space), second - in the second pane, and so on.
if it is not possible in vim, maybe it's feature is implemented in other editors?
Synchronizes two vim panes
Lets say your window is 20 rows, then
:vsplit // splits window into left and right panes
^w^w // focuses right pane
20^e // scrolls right pane down 20 rows
:windo set scrollbind // syncronizes both panes
^w means press and hold CTRL and then press w. Likewise for ^e
:windo means :set scrollbind in all open panes
Implement it in a function
Wraps the above commands in a function and binds it to [
function! SyncScroll()
vsplit
execute "normal! \<c-w>\<c-w>" . winheight(0) . "\<c-e>"
windo set scrollbind
endfunction
nnoremap [ :call SyncScroll()<cr>
You can add the above function and mapping to your vimrc with :e $MYVIMRC and reload it with :source $MYVIMRC
ref:
vim
docs - scrollbinding
wiki - scrollbinding
I think you're looking for the MPage plugin. You probably want to install the latest version from DrChip's page.
Consider I have a NERDTree window and more then 2 file view windows are opened in vim. In this case a common way to switch to NERDTree (navigating with several Ctrl+w g/h/j/k) is not very handy as it is not universal for all the open windows.
Is there a way to switch to NERDTree (or any other, may be) window directly?
<C-w>t
should do what you want.
You can make a mapping to do this:
nnoremap <silent> <Leader>t :NERDTreeFocus<CR>
Depending on your window layout, if NERDTree is near the top-left corner, it may have a fixed window number (:echo winnr() will tell you). You can then use [N]<C-w><C-w> to go to window number [N].
If your layout is more dynamic, it might make sense to include the window number in your 'statusline':
:set statusline+=\ %{winnr()}
How do I scroll the other window in :vsplit in VIM? I've looked everywhere, but all websites are talking about how to sync both windows to scroll together. I want to look at one file, edit it, while scrolling the other.
I'm fairly (ok, quite) certain there's nothing built in to do this, not least of all because it only makes sense when there are exactly two windows. For that specific case, however, you can use a mapping. Put these in your ~/.vimrc:
nmap <a-j> <c-w>w<c-e><c-w>w
nmap <a-k> <c-w>w<c-y><c-w>w
This will make Alt+J scroll down and Alt+K up, you can change those as you like. If you want it to work with more windows, you'll have to write a script.
" SCROLLING FOR OTHER SPLIT WINDOWS (JUST 2 WINDOWS)
nmap <M-j> <c-w>w<c-e><c-w>wh " Scroll down one line other pane
nmap <M-k> <c-w>w<c-y><c-w>wh " Scroll up one line other pane
nmap <M-d> <c-w>w<c-d><c-w>wh " Scroll down half screen other pane
nmap <M-u> <c-w>w<c-u><c-w>wh " Scroll up half screen other pane
nmap <M-f> <c-w>w<c-f><c-w>wh " Scroll down one screen other pane
nmap <M-b> <c-w>w<c-b><c-w>wh " Scroll up one screen other pane
<M> is Meta, Opt, or Alt key. When I tested the shortcut, my cursor in the current window go forward 1 character. So I ended mapping the bindings with h. But these work whenever you don't reach the first or last line of your other pane or the cursor will just switch to your current pane then start scrolling.
Setup: MacVim with MiniBufExplorer plugin window spanning the entire top and Taglist plugin window on the right.
Due to the fact that I keep my Taglist on the right, whenever I open the quickfix window, it is positioned on the far right, below the Taglist window (with the same width as the Taglist window)
Is it possible to change the default opening position logic, so that the quickfix window will open below my main code window (down and to the left) or maybe span the entire width at the bottom of the Vim viewport?
While it is not possible to change the default split-window behavior
of the :copen command, one can approach the issue in two ways.
1. Use the commands that directly alter window splitting directions
(see :help :vertical and below until the “Closing a window” paragraph).
For instance, consider the commands:
:botright copen
or
:botright cwindow
to make the quickfix window open as the bottommost one, or even:
:vertical topleft cwindow
to open it to the top left of the current window.
These commands can be shortened to :bo cope, :bo cw, and :vert to cw, respectively. Also, one can, of course, create a short mapping or
a custom command for their quick invocation.
2. Alternatively, move the quickfix window to the bottom of the window
layout using an auto-command:
:autocmd FileType qf wincmd J
This trigger takes advantage of the fact that the quickfix window can
be easily distinguished by its file-type, qf. The wincmd J command
is equivalent to the
[Ctrl+W,
Shift+J]
shortcut sequence instructing Vim to move the current window to the
very bottom of the screen (see :help :wincmd and :help ^WJ).
By default, Vim opens the new window above the current one for horizontal splits, and to the left of the current one for vertical splits (:help opening-window). You can customize this behavior like most other things in Vim:
make the new window appear below the current window.
:set splitbelow
make the new window appear on the right.
:set splitright