Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

Sunday, March 25, 2012

Update ctags with brew

Update ctags with brew

The "ctags" coming with Mac OS is really a very old one (1993). We can update it with brew, and I think this Article is very useful.

The point is:

  • Install latest ctags with brew: brew install ctags. This should be OK
  • Replace "ctags" with:
    1. alias ctags="`brew --prefix`/bin/ctags"
    2. alias ctags >> ~/.bash_profile
    3. Please note that the original post uses ~/.bashrc but it won't work in Mac OS. So use ~/.bash_profile instead

`brew --prefix` will display the install path of brew, and append it with /bin/ctags will get the new ctags pathname. Please note that "`" is the character with the key "~" on your keyboard.

Saturday, October 29, 2011

Error in .vimrc

So I copy my .vimrc from my PC to Mac. I put it into ~/. But when start MacVim, there is error message like this:

E488: Trailing characters: nocompatible^M

So the vimrc can't be loaded into MacVim. I googled but their solution doesn't work for me. There is a very simple solution is....


1. In terminal:

$mv ~/.vimrc vimrc
$mvim ~/.gvimrc

2. Then in vim:
:tabe ~/vimrc
:gg
:ctrl+v
:G
:y
:tabp
:p


That means, copy the whole content from "vimrc" to ".gvimrc" in MacVim. So the ".gvimrc" will work well.

Friday, October 28, 2011

Vim for Mac

I use vim for many years (on windows), so I also want to use vim on Mac. Because Mac OS is a type of UNIX, so there is a text based vim built-in it. But I want a GUI vim. It seems that MacVim is the best choise for vimer on OSX. You can download it from: https://github.com/b4winckler/macvim, or http://code.google.com/p/macvim/.

After download / install MacVim, there are two method to open it in console:
  • $open -a MacVim
  • $mvim
Let me explain:


1. open -a MacVim
Because MacVim is installed on /Application, so the system allow us to open the app by the name, the path is not needed. It is very handy, but it seems that if you want to edit a file with administrator privilege, "sudo open -a MacVim" can't work. So we need the second method.

2. mvim
mvim is included in the install package of MacVim, you can copy it to a dir, for example, I have a directory: ~/scripts, and I copy mvim into ~/scripts. Then I need to add ~/scripts into the PATH.
Because OSX read the follow configurations when terminal opens (via this):
  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile
So we can edit ~/.profile and add this line:

export PATH=~/scripts:$PATH

into it. So ~/scripts is added into PATH whenever you open a terminal.
Then in terminal, you can just type:
$mvim <path to file>
or
$sudo mvim <path to system file>
to edit.