84

I'm working with the Vim 7.2 that comes with Mac OS 10.6.1 (Leopard), using the Mac's "Terminal" app. I'd like to use a fancy color scheme. I did this...

:syntax on 

Then this...

:colorscheme slate :colorscheme elflord :colorscheme desert etc... 

Syntax highlighting is working, but I'm finding that regardless of the scheme I choose, the only colors displayed are the basic Red, Blue, Cyan, Gray, etc.

Is there a way to get the Terminal app to display a larger collection of colors to allow some more subtle schemes?

6 Answers 6

165

Create a .vimrc file on your home ~/ folder and then edit it with vim ~/.vimrc. You can try adding syntax on inside ~/.vimrc file. The following command does that:

echo "syntax on" >> ~/.vimrc 

It will highlight your code syntax on vim

Sign up to request clarification or add additional context in comments.

5 Comments

This solved my problem of syntax highlighting. By the way, how would one choose various other syntax schemes other than the default ones?
you can modify your vimrc file according to your use. Refer this site dougblack.io/words/a-good-vimrc.html
This should be accepted as the solving answer.
the best solution suggested! easy peasy!
You are a master!!!
27

You need to create file ~/.vimrc and add syntax on in that file

vi ~/.vimrc

syntax on

save the file and run your vim

Comments

22

Add "syntax on" to the file /usr/share/vim/vimrc and you'll get highlighting in your files every time you edit one.

# vi /usr/share/vim/vimrc

Add this line at the end of the file:

syntax on 

Now you'll get highlighting when you edit whatever's file.

6 Comments

Bad idea. Never edit the system vimrc. Edit your own user vimrc instead, either by doing vim ~/.vimrc or from within Vim with :e $MYVIMRC.
I don't whink so. It's improving the functionality of the entire system. Then, the users can also use his own vimrc.
This should be downvoted! You should use user level if .vimrc as glts suggested.
"Bad idea. Never edit the system vimrc." Why not? If you want all users to get syntax highlighting then the system configuration is the proper place to make that change. Else you would have to use /etc/skel or some script to make these edits for all users. The simplest approach is the better approach.
System configuration files are guaranteed to always work. As other users already commented, better to override configurations on your own user directory.
|
20

The Terminal.app supports AFAIK only 16 colors; iTerm supports more colors or you use mvim (as suggested by Daniel).

4 Comments

Just to add an update to this answer, someone has taken it upon themselves to work on an iTerm2, possibly out of frustration with the development pace of the previous iTerm, and while it is in Alpha, it seems to be stable for me (after only a few minutes of playing around). My concern with the original iTerm was its CPU usage, but that seems to have been cut down some in iTerm2, so I think I'm gonna give it a shot.
Just wanted to point out to that Terminal supports 256 colors just fine and has done for the past few releases of OS X. Im using Mavericks (10.9) so its probably true in Yosemite (10.10) too. Unfortunately, it doesn't work inside GNU screen, because the version of screen that ships with OS X (at least in 10.9) doesn't have 256-color support. I used Homebrew to install a newer version of screen. I have verified that 256 colors works both inside and outside of screen, inside Terminal, with my current setup.
@Eno I have install screen from brew but it still not working could u help me with that?
@buncis Maybe this will help gist.github.com/shawnbot/3277580
10

You might want to consider using a version of Vim that is a native Mac app (that runs in a window).

MacVim has great color schemes and you can still launch it from Terminal like so:

$ mvim file.txt 

That will open your file in a new Vim window.

2 Comments

The problem with a somewhat customized MacVim is that it has considerably longer startup times. Still worth using it, though.
No longer native and the link to the site is also down. I'm on macOS Sequoia 15.2
3

@ashcatch - Can't leave a comment, but wanted to add that iTerm has other advantages over Terminal.app such as sensible copy and paste (configurable 'word' regex for easy double click selection of paths/urls, middle click paste) and terminal mouse support (:se mouse=a in vi to get mouse text selection, moving of window borders etc.)

I'd be lost without it.

2 Comments

I use TotalTerminal with OS X's Terminal (which gives you a dropdown Quake-style console tied to a hotkey, ^` by defauilt). Inside this I run multiple tabs, running screen in each tab for different codebases. Terminal supports 256 colors and installing a newer copy of screen with Homebrew gives you 256 colors inside screen too. No need to install another third-party terminal app...
iterm2 rocks.. There is actually (unfortunately) no linux terminal to do what it does...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.