开发者

Vim: change mouse click behavior

开发者 https://www.devze.com 2023-02-09 00:46 出处:网络
I am playing with my vimrc settings, and enabled the mouse support. set mouse=a Now, I miss the copy and paste option with mouse. Normally, if the mouse is not enabled, I could copy text with left

I am playing with my vimrc settings, and enabled the mouse support.

set mouse=a

Now, I miss the copy and paste option with mouse. Normally, if the mouse is not enabled, I could copy text with left click + drag, and paste by right click (in Insert mode). So,开发者_JAVA技巧

How to get the copy, paste with mouse enabled (with mouse click, not Ctrl+v etc). The only option I need with mouse enabled is to click anywhere in the file and the cursor points to that location. This helps faster navigation.

I use putty (x-term) to connect to my debian server.


Easiest solution is just to hold shift down when you select text, to get the old behavior for mouse-copy. Paste with shift-mouseclick will usually work too.


jkerian's solution is generally what I do, but if you ever find yourself wanting to copy and paste a lot, and getting tired of holding down shift, you can do something like this:

" toggle between terminal and vim mouse
map <silent><F12> :let &mouse=(&mouse == "a"?"":"a")<CR>:call ShowMouseMode()<CR>
imap <silent><F12> :let &mouse=(&mouse == "a"?"":"a")<CR>:call ShowMouseMode()<CR>
function ShowMouseMode()
    if (&mouse == 'a')
        echo "mouse-vim"
    else
        echo "mouse-xterm"
    endif
endfunction


On OSX in a Terminal window you need to hold down the fn key when you want to select some text with the mouse in vim that you want to copy. You can tell it's selected as it is highlighted in a different colour (for the 'Homebrew' profile it's blue) as opposed to vim's default highlight colour (e.g. green). Then you can copy the selected text as usual using +C.

And to add if you want to do this in iTerm2 you need to hold down the (Alt/Option) and mouse to select text for copying - see the iTerm2 FAQ for more selection region options.


Hold the shift button and select the text to copy. Then either click middle mouse button or right click to paste in console. To paste in vim, shift+insert in insert mode.

0

精彩评论

暂无评论...
验证码 换一张
取 消