I do not have the || symbol for the "OR" operator on my keyboard. Is there
a
way to type it in the code instead of copy and paste from the internet?
[These directions are based on Visual Studio 2005.]
Go to Tools | Macros | Macros IDE (or press Alt+F11). There should be a root
node in the Project Explorer called MyMacros. If there's no module beneath
in, right-click it and choose Add Module. Then paste the following code into
it:
Sub InsertPipe()
Dim textSelection As EnvDTE.TextSelection
textSelection = CType(DTE.ActiveDocument.Selection(),
EnvDTE.TextSelection)
textSelection.Text = "|"
End Sub
Save it and close the macro editor. Back in the VS IDE, right-click a
toolbar and choose Customize. Then click the Keyboard button. In the "Show
commands containing text" box, type "InsertPipe". The list box below should
be populated with that macro (and probably nothing else). Now pick and
assign a shortcut key. I used Ctrl+Shift+P, which was already assigned to
Run Temporary Macro, but I never use that so it was a good hijack. Hit OK as
needed.
Now you can just press your shortcut key in the editor and get your pipe.
(On second thought, why not use Ctrl+Shift+\ as the shortcut? It's not
mapped to anything in my system and on my keyboard the pipe is right above
the backspace, so it's almost like actually having the character there.)