Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to figure out why I don't have syntax highlighting when editing my crontab.

I have both $EDITOR and $VISUAL set to /usr/bin/vim:

> echo $EDITOR
/usr/bin/vim
> echo $VISUAL
/usr/bin/vim

If I save the crontab to a file and edit it with vim syntax highlighting is enabled.

> crontab -l > saved_cronab
> /usr/bin/vim saved_crontab

And if I use :syntax on while editing the crotab nothing changes

How can I enable highlighting when editing crontab with crontab -e?

share|improve this question
add comment

migrated from serverfault.com Mar 24 '13 at 4:53

This question came from our site for professional system and network administrators.

2 Answers

up vote 0 down vote accepted

Did you export these variables (export EDITOR VISUAL)?

share|improve this answer
    
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  mdpc Mar 22 '13 at 0:40
    
@mdpc Actually it does answer the question, and I'll bet it's the right answer, too. –  Michael Hampton Mar 22 '13 at 1:30
    
@mdpc Probably export is an answer, but you are right - I bit misunderstand "you can answer but not comment" policy. Sorry about that. Should I remove my another "clarification request" (serverfault.com/questions/490255/…) ? –  dsznajder Mar 22 '13 at 5:47
add comment

vim doesn't know, that your file saved_crontab is a crontab. Therefore, you don't get a special syntax highlighting for crontabs. Setting the filetype to crontab worked for me. I used:

:set ft=crontab

You can see the value of filetype with:

:set ft?
share|improve this answer
    
You can also permanently set the modeline for this file by adding a modeline like # vim: ft=crontab to the top of the file. However modelines are disabled by default for security reasons as root and by some distributions. –  Erik Apr 5 '13 at 13:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.