How to Enable VIM Syntax Highlighting on MAC OSX

For some people VIM is the primary code editor and some people use it to make minor edits to their code. Whatever your use case might be, it’s always good to have some syntax highlighting. It makes the code more readable and reduces errors.

Syntax highlighting / Color coding is not turned on MAC by default. Turning it on is a very simple task.

Open your terminal, it will be in Applications/utilities folder.

Type in the following command to open up the VI editor preferences file

vi ~/.vimrc

Most probably it will be empty. Whether its empty or not, add this code at the very end.

filetype plugin indent on
syntax on 

Code to add Syntax Highlighting on MAC

Bonus tip: If you are wondering how we got the line numbers in the above screenshot

  1. Press the Esc key if you are currently in insert or append mode.
  2. Press : (the colon). The cursor should reappear at the lower left corner of the screen next to a : prompt.
  3. Enter the following command: set number.
  4. A column of sequential line numbers will then appear at the left side of the screen.

You can even add set number at the end of above two lines in ~/.vimrc to make it always show the line numbers.

vi without color coding
vi without color coding
VI with color coding and line numbers enabled
VI with color coding and line numbers enabled

5 Less Known Mac OS X Tricks

Although, most of the experienced Mac users already tried these tricks, but if you are new in Mac, you can follow the following tricks to get more out of your Mac. If you use these tricks, you do not have to install any third-party software to do a particular task, sometime you do have to find a complicated setting in your Mac. All these tutorials are much easy to use.

5 less known Mac OS X Tricks

Set Custom Message in Log in Screen

Set Custom Message in Log in Screen

Mac requires a password at several times just like Linux. Although, you can allow automatic log in, which won’t ask any password at startup but if you want to make your Mac secure, this is recommended to disable automatic log in. When you disable automatic log in, you will start getting a log in screen just like Windows and other OS during startup, where you will have to enter your password.

However, you can show custom messages on your log in screen that may be helpful if you have forgotten your MacBook at any public place and someone is trying to log in to your Mac. He/She can easily check your custom message and you will get your Mac back if you have a good luck. To set a custom message in your Mac’s log in screen, just follow the following steps:

Go to System Preferences >> Security & Privacy >> Unlock to Make Change >> Tick on “Show a message when the screen is locked” >> Set Lock Message >> Write down your message

Disable Drop Shadow in Screenshot

Alike Windows, Mac comes with an in-built screen capture tool. You can simply press cmd + shift + 3 or cmd + shift +4 to capture your screen. However, if you have checked your captured screenshots minutely, you might have already seen the huge drop shadow around the screenshot. This default setting/customization might be annoying at some moments.

Nevertheless, don’t worry. You can easily disable this drop shadow within seconds. To do so, just open your Terminal and enter the following command:

defaults write com.apple.screencapture disable-shadow -bool true

Now, you have to restart your Mac to get the change.

Save any Screenshot as PDF

Suppose, you have to send some screenshots to someone in PDF. Generally, most of the Mac users use many Image to PDF converter to convert captured images into PDF file. But, do you know that you can do this conversion without installing any third-party software? To do so, open your Terminal and enter the following command:

defaults write com.apple.screencapture type pdf;killall SystemUIServer

Now, you may have to restart your PC.

Show Hidden Files and Folders

By default, you won’t get any system created files (.DS_Store) or any other self-made hidden files in your Mac. Sometime, we need to show hidden files to do something important. For example, you have hidden some files from your Windows and wanted to use that in your Mac. At such moment, you can simply use this following Terminal command:

defaults write com.apple.finder AppleShowAllFiles YES; killall Dock

Set Any Image as Folder Icon

This is one of the best tricks you can do. Although, Windows does not allow users to do so without having any third-party software but you can set any image as folder icon without installing any software in your Mac. To set any image as folder icon, just right-click on any folder and select Get Info. Then drag and drop the image on the default folder icon that is situated at top left.

Set Image as Folder Icon Mac

Bottom Line

When you are using Mac, you can easily customize it as per your wish. You can always find a great solution or trick to do whatever you want. Stay tuned to get more Mac tricks.