How to comment in a Right to left language in Visual Studio IDE

You can simply put an RLE (RIGHT-TO-LEFT EMBEDDING, U+202B) character before your paragraph. This control character is also supported in browsers and most text editors.

Without RLE:

 // متغیر _value برای نگهداری مقدار اولیه ی کالا می باشد.

With RLE:

 //‫ متغیر _value برای نگهداری مقدار اولیه ی کالا می باشد.

I use this template for my RTL comments (you must press END button, not going between quotation marks):

// '‫'

Also for Python:

# '‫'

Edit:

In Visual Studio Code, you have to set "editor.renderControlCharacters": false in settings.

Also you can set a keyboard shortcut for editor.action.toggleRenderControlCharacter.


As Ahmad mentioned Microsoft does not support Right-to-left in its Visual Studio IDE (unfortunately), to copy and paste the comment form a RTL-supported editor also does not work (I test it with Notepad)

For this purpose, I have developed an extension for visual studio 2013 (VirtualRTLtext), it rearranges the words of a line of comment so that it will looks correct in Visual Studio code editor.

Rearranging words works well for usual comments but in case of XML comment it has some problems:

  1. When you want to make XML documentation from your comments
  2. When you want your comments in intellisense

For the first, i could find a partial solution but for the second, this algorithm does not work (because length of lines in intellisense and code editor is not equal).

To download it in Visual Studio go to TOOLS/extension and updates... and search VirtualRTLtext

Or get the vsix form Here.

After installation you could find it in VIEW/Other Windows

enter image description here