DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 18th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Thanked 8 Times in 8 Posts
Default Syntax Highlighting

Hello,

What is your take on syntax highlighting? I must admit, I find it a very useful feature - but not all editors support it.
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #2   (View Single Post)  
Old 18th June 2008
sverreh's Avatar
sverreh sverreh is offline
Real Name: Sverre Hval
Port Guard
 
Join Date: Apr 2008
Location: Norway
Posts: 36
Thanked 6 Times in 5 Posts
Default

I like it too. Helps a lot when searching for errors in scripts with VIM. (Of course, since I almost never produce faulty scripts, I don't need highlighting)
Reply With Quote
  #3   (View Single Post)  
Old 18th June 2008
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 358
Thanked 9 Times in 8 Posts
Default

It seems many editors, particularly on Windows machines, make your editor look like a circus. I ran my code through an editor once and counted seven different colors including hot pink. Too often, code words are highlighted because they can but it serves no purpose.

I can see where highlighting of certain significant keywords can be helpful, but I'm not entirely convinced of this either. I frequently find highlighting just grabbing my attention while scanning and distracting me.

In typography, highlighting is used just for that. To grab your attention so you don't miss something. Do you want to do that while reading through the logic of your code? I always tell myself I'm going to experiment with this but haven't yet. I might like highlighting when I'm searching for a keyword but not otherwise.

I think some like colored highlighting because it seems to make the page more attractive to look at. I also think this is only a temporary effect which quickly wears off and, again, only causes distraction and confusion.
Reply With Quote
  #4   (View Single Post)  
Old 18th June 2008
RandomSF RandomSF is offline
Port Guard
 
Join Date: May 2008
Location: Hartland, WI, USA
Posts: 13
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by sverreh View Post
(Of course, since I almost never produce faulty scripts, I don't need highlighting)
Right, but when I am sent to correct the mistakes of others it's still quite handy.

I also use Vim and just pick a color scheme that provides decent highlighting without driving me insane. I find that I use different color schemes on different computers probably because of differences in monitors and lighting.
Reply With Quote
  #5   (View Single Post)  
Old 18th June 2008
deemon's Avatar
deemon deemon is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Estonia
Posts: 50
Thanked 6 Times in 5 Posts
Default

Quote:
Originally Posted by drhowarddrfine View Post
Do you want to do that while reading through the logic of your code?
It's exacly opposite for me - highlighting different parts of code - keywords, braces, strings, variable defs, etc - helps to navigate and read the code. It's easier to discard different parts of your code and only see that which is important.

Syntax highlighting has no downsides for me. Atleast in the editors I use (which consists of gvim / vim in xterm only).
Reply With Quote
  #6   (View Single Post)  
Old 18th June 2008
sverreh's Avatar
sverreh sverreh is offline
Real Name: Sverre Hval
Port Guard
 
Join Date: Apr 2008
Location: Norway
Posts: 36
Thanked 6 Times in 5 Posts
Default

Quote:
Originally Posted by drhowarddrfine View Post
In typography, highlighting is used just for that. To grab your attention so you don't miss something. Do you want to do that while reading through the logic of your code? I always tell myself I'm going to experiment with this but haven't yet. I might like highlighting when I'm searching for a keyword but not otherwise.
Well, it can be useful for other purposes. Just to give an example: If you forget the closing $-sign for a mathematical expression in a .tex file, all the rest of your document will be shown in wrong colours. Very easy to notice the mistake. I also like it when working with Perl or shell scripts, where operators, variables and constants are shown in distinct colours. Helps me, not just because it is "pretty". But it is all probably a matter of taste, and it does take some time to get used to it. I agree that it can be a bit distracting in the beginning. Give it a try, you may end up liking it. (And then you will be lost when you have to work on a system without a highlighting editor.
Reply With Quote
  #7   (View Single Post)  
Old 18th June 2008
halber_mensch's Avatar
halber_mensch halber_mensch is offline
Real Name: halber mensch
Port Guard
 
Join Date: Jun 2008
Location: Sapulpa, OK
Posts: 14
Thanked 1 Time in 1 Post
Default

On a similar note, paren-highlighting is also a coder-friendly feature, especially when you've nested several levels of parens and brackets. It's one of the things I really enjoy about the language major modes in emacs. When your cursor is on a paren or you type in a paren, if it has a partner the cursor flashes on it briefly, or you get a status message indicating an unmatched paren. It saves a lot of counting =)
__________________
perl -e "eval pack(q{H*}, join q{},qw{7072696e74207061636b28717b482a7d2c717b34393 23036333631366532303666366536633739323036313733373 33735366436353230373936663735323036353738373036353 63337343635363432303734363836393733323037343666323 03632363532303631323036633639373437343663363532303 66436663732363532303635366537343635373237343631363 93665363936653637326530617d293b})"
Reply With Quote
  #8   (View Single Post)  
Old 18th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Thanked 8 Times in 8 Posts
Default

Hello,

Some of the benefits of syntax highlighting (at least as in done in vim) are:

If you mistype a keyword or forget a quote or semicolon, the coloring is all out of whack - no need to wait until compile time to realize a mistake is made.

Brace matching allows you to easily if you have enough braces and to see logical deliminations of blocks of code.

I have heard that staring at large chunks of plain code for hours on end - it all looks the same (I haven't spent hours at a time in front of plain code to know this first hand).



^^^ The second item could be easily lived without, but as to the other two - those who do not use syntax highlighting, could you please expound on why plain code is superior to syntax highlighting or where syntax highlighting falls short of desired results.
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
  #9   (View Single Post)  
Old 18th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Thanked 8 Times in 8 Posts
Default

Hello,

Most vi clones (i.e., vim) have developed syntax highlighting as part of their editor. Is there anyway to incorporate syntax highlighting with (n)vi?
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
Old 18th June 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

I suppose when it comes to text editing, decent editing keybindings/mappings (e.g. no need for a mouse) and syntax highlighting is probably about all I really ask for.


I think I agree with people in #vim, code should _not_ look like a Christmas tree !!!


I like syntax highlighting because I spend a lot of time in text editors, which is probably why I like nvi and vim. The first time I tried creating a color scheme for Vim that took over my syntax highlighting.. I found the colours to distracting and chucked it.

In Vim I use the 'astronaut' colo in a pseudo transparent terminal and find find it to have very good effects on syntax highlighting.


Some keywords are underlined and coloured, keywords and some types of things coloured, strings colored differently + diff colour for %stu \ff and coloured comments.

I loved astronaut so much for Perl and felt so at home with it for Python, that I created my own personal colour scheme based on it.


I like syntax highlighting when it _helps_ me. If you really know how your syntax highlighting works, you can use it to quickly scan bits of information and differentiate parts of code quickly.


One thing I do like is providing a highlight of some sort for {}. (), [], and when XML/SGML based stuff is around <tag></tag>.


I've found syntax highlighting very helpful for Perl, PHP, LaTeX, and XHTML in particular. Especially if I forget a freaking sigil or start a string with ' or " and end it with the opposite one by mistake

I can use the warning/error messages and the syntax highlighting to quickly locate the offending code. Now if only there was a way to make vim add missing ';'s on :w hehe.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Old 19th June 2008
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 358
Thanked 9 Times in 8 Posts
Default

Quote:
Originally Posted by sverreh View Post
Give it a try, you may end up liking it. (And then you will be lost when you have to work on a system without a highlighting editor.
I "gave it a try" years ago, for years, so I don't need to do that. In geany, I tried setting some simple highlighting but I'm not sure what works best. I kind of like bold function names in dark blue but when I'm not searching for function names, they get in the way. Some of the posts here mention certain highlighting functions which aren't syntax highlighting but error checking. And as far as staring at monochrome all day, it's my preferred method and with no X.
Reply With Quote
Old 19th June 2008
JMJ_coder JMJ_coder is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 464
Thanked 8 Times in 8 Posts
Default

Hello,

Quote:
Originally Posted by drhowarddrfine View Post
Some of the posts here mention certain highlighting functions which aren't syntax highlighting but error checking.
Could you expound on some alternatives then for said error checking?
__________________
And the WORD was made flesh, and dwelt among us. (John 1:14)
Reply With Quote
Old 20th June 2008
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 358
Thanked 9 Times in 8 Posts
Default

Your thread is about syntax highlighting, not error highlighting.
Reply With Quote
Old 20th June 2008
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Old man from scene 24
 
Join Date: Apr 2008
Location: Eindhoven, Netherlands
Posts: 2,064
Thanked 198 Times in 156 Posts
Default

I find syntax highlighting very useful, not only does it let you scan text much faster, it also lets easily detect simple errors (like a missing */).

I use Vim's default color scheme, it works well, although I do recommend enabled 256 colors, it offers just that extra little bit of extra contrast over the default 16 colors ... See:
http://vim.wikia.com/wiki/256_colors_in_vim
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
Old 21st June 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

Quote:
Originally Posted by drhowarddrfine View Post
Your thread is about syntax highlighting, not error highlighting.
Syntax highlighting highlights elements of visible text based on a defined syntax.

If missing an ending " makes the rest of my file highlight as a string until I type the ending quote, I ain't got a problem that feature. I consider it just a part of selectively changing text colours (highlighting) based on syntax ;-)
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Old 22nd June 2008
ai-danno's Avatar
ai-danno ai-danno is offline
Spam Deminer
 
Join Date: May 2008
Location: Boca Raton, Florida
Posts: 284
Thanked 35 Times in 31 Posts
Default

It's been mentioned twice that it helps with PERL... and I would completely agree with that... perhaps a junky color scheme might be distracting, but one that is contrasting enough but that also isn't offensive seems to be the most useful for me concerning PERL scripting.
__________________
Network Firefighter
Reply With Quote
Old 22nd June 2008
corey_james corey_james is offline
Uber Geek
 
Join Date: Apr 2008
Location: Brisbane, Australia
Posts: 238
Thanked 4 Times in 10 Posts
Default

I don't think there's anything that irritates me more than syntax highlighting.

I'm not 100% sure why i don't like it but i think i focus more on the colours than the actual code.

Drives me nuts logging into a *nix machine where i can't navigate around the fs or edit a file without getting a rainbow appearing in my terminal window hehe
__________________
"No, that's wrong, Cartman. But don't worry, there are no stupid answers, just stupid people." -- Mr. Garrison

Forum Netiquette
Reply With Quote
Old 22nd June 2008
drhowarddrfine drhowarddrfine is offline
VPN Cryptographer
 
Join Date: May 2008
Posts: 358
Thanked 9 Times in 8 Posts
Default

My point exactly, corey, but I wonder if it's a matter of personal preference or not really noticing the difference.
Reply With Quote
Reply

Tags
vim

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl expression syntax qsecofr Programming 3 16th February 2009 12:56 PM
C/C++ Syntax highlighting in emacs rex FreeBSD General 1 12th October 2008 03:21 AM
I need help with make.conf syntax troberts FreeBSD Ports and Packages 4 1st June 2008 03:58 AM
Vi type syntax applications corey_james Off-Topic 9 28th May 2008 04:15 PM
relayd (and hoststated) give syntax error for 'check script' gwl OpenBSD Security 2 2nd May 2008 04:53 PM


All times are GMT. The time now is 02:52 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick