Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I want to comment in visual studio in Persian (which is a right to left language) like this:

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

But it seems the code editor does not support RTL languages and reorders the words so the result is:

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

That does not read as I expected!

Anybody have a solution for this problem?

like image 375
Hosein Masoomi Avatar asked Jan 26 '15 12:01

Hosein Masoomi


People also ask

How do you write from right to left in VSCode?

To move the text to the right, click Edit > Shift Right. To move the text to the left, press Shift+Tab. To move the text to the left, click Edit > Shift Left.

How do I comment all lines in Visual Studio Code?

Comment Code Block Ctrl+K+C/Ctrl+K+U If you select a block of code and use the key sequence Ctrl+K+C, you'll comment out the section of code. Ctrl+K+U will uncomment the code.


2 Answers

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.

like image 129
Reza Nooralizadeh Avatar answered Oct 18 '22 17:10

Reza Nooralizadeh


I recently wrote an extension for vscode that allows you to leave comments from right to left. You can use the result that returns, in Visual Studio or any other program. "RTL Comment Support" do it for you.

like image 29
Rouhollah Torshizi Avatar answered Oct 18 '22 16:10

Rouhollah Torshizi