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.
Related
I have a problem: When I initiate Operator-Pending Mode with d or c and I click on the active window, the mouse click acts as a motion. For example, I can position my cursor at the start of a paragraph, press d, then click on a word at the end of the paragraph and Vim will delete from the cursor position to the end of the paragraph. I would like to disable this feature to prevent accidental mouse clicks.
I have added the following in my .vimrc, which tells Vim to enable the mouse only in Normal Mode and Visual Mode.
set mouse=nv
However, this does not work. I can enter Operator-Pending Mode and still use a mouse click as the motion. Is it possible to tell Vim not to accept mouse clicks for motions in Operator-Pending Mode?
:help 'mouse' won't help, here, so you can set it to a or any desired value.
You could disable the left mouse in operator-pending mode, though:
onoremap <LeftMouse> <Nop>
which prevents mouse clicks motions in operator-pending mode. Note that, with that mapping, a mouse click is not considered as a motion anymore but it also sort of "breaks out" of operator-pending mode, which may or may not be a problem.
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
I saw this key bind in tips.txt:
:map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>
Which results in smooth scrolling up for CTRL-U. It only moves the viewport though, and I'd like to also move the cursor, so for scrolling down I tried:
:map <C-D> <C-E><j><C-E><j><C-E><j><C-E><j><C-E><j><C-E><j><C-E><j><C-E><j>
Since CTRL-E moves the viewport down and j moved the cursor down. This doesn't work however. When I press CTRL-D the viewport just hops one line down and the terminal beeps.
How do I map CTRL+D to scroll and move the cursor?
You shouldn't have the angled brackets (</>) around j.
I just discovered :set mouse=a. Amazing thing, it allows my coworkers to scroll over my openend files.
But here is the thing : I really don't want the cursor to move when I left-click somewhere. I don't want either the standard cursor which :set mouse=a brings (I want to keep the default text cursor).
In others words : is there a way to enable mouse scrolling in VIm without enable other support mouse stuff ?
Thanks.
EDIT - other idea : can I bind the wheel mouse UP to do the same thing that Page Up key ? It would be awesome !
Try this mapping:
:nnoremap <LeftMouse> <nop>
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