I was searching on internet, but zero results. Anyone knows?
I'm using IBM DataStudio 4.1.1.
Regards.
If you mean the shortcut to turn lines of code into comments then it's Ctrl + /
Use "--" double hyphen to comment SQL code in Data studio
Related
my coworker and i wonder if there is a way to teach visual studio to do something like emacs is able to: place the cursor anywhere in a series of whitespace in code, press ALT-SPACE shortcut (or the defined one) and boom only one space character left.
does anyone know if a simple solution exists to do this? maybee even without installing extensions or other stuff?
i already tried shortcuts like STRG-DEL but it depends on the cursor position what is deleted and that is not exactly what we are searching for.
thanks in advance, cheers! jens
ps: caps lock is reverse broken, sorry...
You could try this :
Ctrl + H
Find what:
[\u0020]+\r?\n
Replace with:
\r\n
\s instead of [\u0020] delete empty line feeds, probably because it matches line feeds
i just found out... VS HAS a feature to do this... unfortunately, in 2012 it is not working, in 2015 is is... weirdo... default is
STRG + E, ^
you also find it in EDIT >> ADVANCED menu.
best regards,
jens
**Ctrl+E, Ctrl+** is what works on my keyboard, not sure what 'strg' is, maybe a different term for 'control"?? You can also achieve this with **Ctrl+K, Ctrl+** (a keyboard "chord"), as long as you have your cursor within the spaces you want to reduce.
In some cases in Visual Studio 2015, these spaces will be eliminated when you press the chord for file reformatting in general: Ctrl+K, Ctrl+D. However, it seems to depend on factors I'm not certain of... something I'll be posting about in StackOverflow later.
I'm refactoring some code and there are tons of functions with no try catch statements that are causing problems.
Is there a keyboard shortcut in VS 2010 to allow me to select an entire function or highlighted code and add a try catch end try statement around it...with the highlighted code automatically ending up under try ?
Just looking for a shortcut
I'm not aware of a keyboard short-cut, but there's a right-click available.
Highlight the code for your try block.
Right click and select
"Surround with..." Scroll down the selection until you see the "try"
snippet label.
There you go!
Hope this helps!
I'll dig around to see if there's a keyboard short cut for this. There probably is -- there's hundreds of them.
UPDATE: Looks like the keyboard shortcut is Ctrl + K, Ctrl + S.
Download this free addon and then right click and surround with !
(Don't forget to give it 1+ )
https://marketplace.visualstudio.com/items?itemName=yatki.vscode-surround
It's not built in, but it is easy enough to roll your own.
Look into using the built in macro facility.
2023 Update
they added this functionality, but only for JS/TS... Let's hope they add this also for other languages like python soon!
Can it be done? We're using VS2005, VS2008, and VS2010.
I don't mean regular expressions—which have their place—but plain old text find and replace. I know we can do it (at a pinch) with regular expressions using the \n tag, but we prefer not to get tangled up in regex escape characters, plus there's a readability issue.
If it can't be done, what plain and simple (free) alternative are people using? That doesn't involve knocking up our own macro.
I finally found it...
There isn't any need to download and load any external macro.
It’s working in Visual Studio 2008 with in-built macro at least. :)
Steps:
Select text you want to find.
Press Alt + F8 or open "Tools -> Macros -> Macro Explorer"
Double click Sample → Utilities → FindLine. (It will open the Find box with your selection loaded in the "Find" field. Don't worry about truncated text shown in the "Find" field. Trust me, the field has it all... The Microsoft way of showing it may be... :) )
Click on the "Quick Replace" button in the "Find And Replace" dialog box. Enter your replace with text.
And click any of three buttons as per your requirement...and it’s done. :)
Hurray... it’s working. It may not be a straightforward way to do it, but you know with Microsoft. Nothing is straightforward and easy.. :)
This works today in Visual Studio 2012:
fooPatternToStart.*(.*\n)+?.*barPatternToEnd
See how the (.*\n)+? part does the match across multiple lines, non-greedy.
fooPatternToStart is some regex pattern on your start line, while barPatternToEnd is your pattern to find on another line below, possibly many lines below...
Example found here.
Simple and effective :)
Note: before VS2012, the pattern that worked was: fooPatternToStart.(.\n)+#.*barPatternToEnd
You can search for multiline expressions by clicking on the "Use Regular Expressions" checkbox in the "Find and Replace" dialog. Line breaks are then indicated by \n.
I use this:
Visual Studio Gallery Multiline Search and Replace
It’s provided by Microsoft only. Please check Multiline Search and Replace.
It uses regular expression only. But for those who don't know regex, it is better to use it.
You could also open the files with UltraEdit which fully supports MultiLine replace.
You can use the trial version if you only intend to use it once.
Regarding the comment of Andrew Corkery:
If you like to specify a multi-line replacement string as well, edit the macro code and set the replacement text as shown below.
This will allow you to "fine-tune" your replacement with just the small modifications needed.
Sub FindLine()
Dim textSelection As TextSelection
textSelection = DTE.ActiveDocument.Selection
textSelection.CharLeft(True)
DTE.ExecuteCommand("Edit.Find")
DTE.Find.FindWhat = textSelection.Text
' Also preset replacement text with current selection
DTE.Find.ReplaceWith = textSelection.Text
End Sub
The latest version (as of this posting) of Notepad++ does multi-line find/replace. With no macro support in Visual Studio any more, this is relevant now.
Is there a way to comment various lines at the same time in Xcode IDE? Selecting which lines to comment, then clicking somewhere et voilá.. the /* ... */ characters wrapping the code.
Thank you.
Command + Shift + 7
or
Command + /
This inserts // in front of every selected line.
Xcode Version 6.1
Shortcuts:
To Comment: Select the code to be comment, ⌘ + /
To uncomment: Select the code an press ⌘ + /
Also see taskbar Editor>Structure "(un)Comment Selection" as user 2137640 pointed out.
The answer is actually very simple if you want to comment a continuous sequence of lines. Select the consecutive lines, then simply press ⌘ /.
I have no idea how to comment multiple non-consecutive lines. Maybe somebody else can help with this, if it is even possible (I doubt it.)
I've been using the Command + Shift + 7 for years, but now in Xcode 13.1 it just started to open the help menu instead of commenting the selected block.
Apparently the new command for commenting a selection of code is:
Command + Shift + ?
Edit:
Another solution is to deselect "Show Help menu" in settings > keyboard > App Shortcuts
There is such a function in the menu. Try: Edit->Insert Text Macro->C->Comment Section.
It will create a (multi-line) comment around the currently selected text.
However, using the menu is probably often slower than manually inserting the comments. But, you can also bind a key to the menu item via the preferences key binding settings.
For single line Comment use ⌘+/
For multiline Comment you need to install CComent plugin
to install plugin manager use alcatraz
new Xcode 14:
Keys: Command + '
in Xcode 7.x
Shortcuts:
To Comment: Select the code to be comment, ⌘ + /
To uncomment: Select the code an press ⌘ + /
Got it! You have to un-indent the lines so the comments are the first character on the line, not a tab or whitespace - then pressing CMD+/ works. Just tried it in XCode 5.1.1, works like a charm.
This worked !
Higlight the desired lines then press Command + /
The same rule goes for uncommenting.
For xcode 8 ->
sudo /usr/libexec/xpccachectl
restart your computer
In Turkish keyboard cmd + *
You can use uncomment and multiline comment.
I'm using Notepad++ as an editor to write programs in Python. It might sound daft but I looked around in the editor and could not find any means (not the manual way but something like in Emacs) to do a block comment in my code.
Since so many language settings are supported in Notepad++, I'm curious to find a way to block comment code.
CTRL+Q Block comment/uncomment.
See Keyboard And Mouse Shortcuts - Notepad++ Wiki.
Try the following shortcut:
Ctrl+K.
This link was exactly what I was searching for .
Let me summarize the answers for others' benefit (for python and notepad++)
1) Ctrl+K on multiple lines (i.e. selected region) allows you to block comment.
Also note that pressing the combination multiple times allows you to add multiple "#"s (sometimes I use that while testing to differentiate from other comments)
2) Ctrl+Shift+K (on the commented region) allows you to perform block uncomment
3) Ctrl+Shift+K on an uncommented selected region does not comment it
4) Ctrl+Q allows you to block comment/uncomment in a toggled mode (meaning, you cannot add multiple '#'s like in 1) )
Hope this helps another wandering soul.
Question - how would you develop a hack of keyboard combinations to comment/uncomment if there were no shortcuts? Just curious. I've no clue hence asking.
Yes in Notepad++ you can do that!
Some hotkeys regarding comments:
Ctrl+Q Toggle block comment
Ctrl+K Block comment
Ctrl+Shift+K Block uncomment
Ctrl+Shift+Q Stream comment
Source: shortcutworld.com from the Comment / uncomment section.
On the link you will find many other useful shortcuts too.
for .sql files Ctrl+K or Ctrl+Q does not work.
to insert comments in .sql files in Notepad++ try Ctrl+Shift+Q
(there is no shortcut to uncomment the code block though. I have tried that on v5.8.2 )
Use shortcut: Ctrl+Q.
You can customize in Settings
In your n++ editor, you can go to
Setting > Shortcut mapper
and find all shortcut information as well as you can edit them :)
Two ways for block commenting:
Ctrl+Shift+Q
or
Select the block
Alt + Right click
Choose block comment.
Without having selected a language type for your file there are no styles defined. Comment and block comment are language specific style preferences. If that's a PITA...
To select for multi-line editing you can use
shift + alt + down arrow
To add a comment under any code on NOTEPAD++ first we have to save and define the programming or scripting file type. Like, save the file as xml, html etc. Once the file is saved in proper format you will be able to add a comment directly using the shortcut ctrl+Q
Just select the desired line and click on Ctrl + Q
Ps: I am using Notepad++