开发者

Change the color of i,j,k in Visual Studio

Can the colors of the letters, i, j, k, be changed when used as an index? For example, i could be reddish, j could be blueish and k greenish. It would be nice to use for other sets as well, such as l, m, n.

I think having more distinction between i, j would help with some indexing errors from typos.

Edit

I should note that the indexing is not just for a triple loop. That's easy enough and as others pointed can be removed with linq. The application is in a scientific code wh开发者_JAVA百科ere mixed derivatives are being calculated across a 3d mesh with finite differences. There the indexes mix up a lot and its not something that can easily be abstracted. Anything that can hits the performance of the code hard.


I realise it doesn't directly answer your question, but another (perhaps better) way to prevent such errors is to use well-named variables for loop indexes instead of the traditional i, j and k.

While most people agree well-named variables are important, there are a lot who still stick with these index variables - I'd same the same rules apply to them and they should have good names.

The tricky part, of course, is coming up with the names..


A tangential answer: Perhaps you need to try an alternative programming font, one which distinguishes more clearly the difference between i,j, and k?

(Oh, the irony of editing this in a monospace font and then seeing the answer posted in glorious proportional sans-serif.)


I'm sure it could. Products like ReSharper and CodeRush change the color coding of various source code elements all the time. CodeRush Express is free and might give you a helping hand towards accomplishing your goal in a relatively painless manner. Download it from http://msdn.microsoft.com/en-us/vcsharp/ee663901.aspx.

Having said that... if you're running into confusion about the names might it not be more appropriate to either a) use more meaningful names or b) refactor so you aren't nested as deep in a single method? Obviously it would depend on what you're trying to accomplish with your nested loops - if it's something obvious then color coding may be an appropriate choice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜