11

When commenting, I recently came across an issue when I needed to explain instance variables using the Ruby syntax @variablename; of course, I'm only allowed to mention one user per comment, so this proved tricky.

How do I stop comments from automatically creating user links when @ is used, and simply be interpreted as plain text?

  • 1
    When I read this title, I thought you meant "escape" as in "run away from". Disappointed that you're not fleeing from your inbox =) – Josh Darnell Jan 6 '12 at 0:24
4

If you are using a keyboard layout that doesn't have the backtick, use \@ instead of @. That avoids the character is thought to be a @-reference, and allows it to be used.
I am using the Italian keyboard layout, and the keyboard doesn't have the backtick. (I have to use the Italian 142 layout, and switch to it when I need to print a back-tick.)

Doing this shows up the backslash, but if you don't have a keyboard with the backtick, this at least avoids the warning message.

If you are using a keyboard that allows you to enter a backtick without changing keyboard layout, since you are referring to a variable name, you can simply wrap the variable name with backticks (e.g. @variablename) which works on comments too.
In my case, I switch to the Italian 142 layout and press alt-gr+ù just for the time to write the backticks; then I switch back to the usual Italian layout, which allows me to enter #, [, or ].

  • Simple, really should have thought of that. Cheers. – Yule Jan 5 '12 at 23:28
  • 2
    Sadly the \ still shows up, but this does work – Michael Mrozek Jan 5 '12 at 23:36
  • @Yule This should work too: @variablename. – kiamlaluno Mar 19 '18 at 9:39
  • @Yule \@variablename shows the backslash, which could not be what you want. – kiamlaluno Mar 19 '18 at 9:40
  • @MichaelMrozek Yes, I should have make that clear. I reported this trick for those users who don't have the backtick in their keyboard. I am using the Italian keyboard, and outputting a backtick is not that easy: It requires using a second Italian keyboard layout which then doesn't make possible to output other characters. – kiamlaluno Mar 19 '18 at 9:42
17

Use backticks ` to make the @ mention into an inline code block.

  • Reasonable suggestion, however not applicable in this case as wouldn't want the text to look like code in this particular scenario. Good to know you can do this though – Yule Jan 5 '12 at 23:31
  • 4
    @Yule Admittedly, I like kiam's suggestion better, but isn't your @variable representing something in the code anyway? Hehe. – jonsca Jan 5 '12 at 23:33
  • 2
    It is representing something in the code, but it's not actual code. It's discussing the use of \@variables, rather than a particular \@variable in the question – Yule Jan 5 '12 at 23:35
  • 1
    I think this approach looks more natural in most cases. +1 – Josh Darnell Jan 6 '12 at 0:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .