How to let vim behave on Mac OS X as on Ubuntu?

柔情痞子 提交于 2019-12-21 20:29:11

问题


Recently I started using a Macbook Pro. Installed is Mountain Lion and so far everything is good. I'm coming from Ubuntu and being pretty much addicted to vim, I can't really stand how Mac Os X is treating vim. ;)

For instance, if I use the mouse in Ubuntu to scroll up, the max I can scroll is the top of the file when a file is open. When I try that in Mac Os X, I scroll straight into the shell history. I'd like the Ubuntu behaviour better, because I find it easier and more logical (even though I know that vim is a 'terminal' application).

Is there anything I can do about this?

I have iTerm2 installed if that helps.

Please note, I'm using the regular Vim, not Macvim of which I read a lot of things also. I prefer to use the original 'vim' because I'm familiar with the keys/commands etc.


回答1:


Terminal.app does not support the mouse.

If you want the mouse you can to install iTerm2 which does support the mouse.

In iTerm2: go to Preferences -> Profiles -> (current profile) -> Terminal and Make sure Enable xterm mouse reporting. After you select this you might need to restart iTerm2.

To enable mouse support in vim add the following to your vimrc

set mouse=a



回答2:


FDinoff has already dealt with the main part of your question but allow me to tell you a few things about MacVim:

  • Like GVim on Linux or on Windows, it's only a GUI built around Vim. You can use the features provided by the GUI (menus, dialogs, wider color palette...) but you are not forced to as it doesn't change Vim's behavior. You have the same commands and everything as in CLI Vim.

  • It's a more complete and up-to-date build than the default build provided by Apple. The lack of clipboard support alone is a good reason to choose MacVim over default Vim.

  • It's extremely easy to install: download, drag, drop, done.

  • It comes with a CLI wrapper that allows you to:

    1. launch the GUI from your shell, $ mvim filename

    2. use MacVim's bundled CLI executable in your shell, $ mvim -v filename

  • If you use Homebrew, it is fairly easy to install a bleeding edge build.

Wait! I think I've already talked about all that... Whatever.




回答3:


I am running Vim 7.4 on Mac Os X Snow Leopard (10.6.8) and I never had issue with the mouse support using iTerm until yesterday, when all mouse functionalities suddenly stopped working.

My .vimrc already contained set mouse=a but I still could not use the mouse functionalities.

I found the solution to my problem here "set mouse=a" in vim doesn't work in screen, you need to add to your .vimrc the following line

set ttymouse=xterm2

This brought back all mouse functionalities.




回答4:


I am on OS X 10.8, and after adding set mouse=a in ~/.vimrc and installing MouseTerm (after installing SIMBL 0.9.9), I could scroll with my mouse on vim in my terminal (using TotalTerminal, by the way).



来源:https://stackoverflow.com/questions/17686811/how-to-let-vim-behave-on-mac-os-x-as-on-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!