How to comment & uncomment multiple line SQL code in DataGrip IDE - datagrip

I would like to comment out queries with a keyboard shortcut, like so
SELECT *
FROM Academics
WHERE Academic_id = 1
To become
--SELECT *
--FROM Academics
--WHERE Academic_id = 1

Select SQL code
SELECT TOP 3 * FROM CUSTOMER WHERE Customerid ='4de3092d03b742f3b2b88cf6fe0b09d0'
Press CTRL + / (or CMD + / on Mac) on the keyboard
Code will be commented
--SELECT TOP 3 * --FROM CUSTOMER --WHERE Customerid ='4de3092d03b742f3b2b88cf6fe0b09d0'
If you need to uncomment it, you need to mark commented code and press the same keyboard combination CTRL + / (or CMD + / on Mac) on the keyboard Code will become uncommented again:
SELECT TOP 3 * FROM CUSTOMER WHERE Customerid ='4de3092d03b742f3b2b88cf6fe0b09d0'

/*
SELECT *
FROM Academics
WHERE Academic_id = 1
*/
Same as:
--SELECT *
--FROM Academics
--WHERE Academic_id = 1
If you're working with SSMS, use CTRL + K, then press C for "comment" or U for "uncomment"

If you are using SSMS, you can go to:
Tools - Options - Keyboard (under Environment)
type in 'comment' in the 'Show Commands containing:"
select Edit.CommentSelection
select 'Text Editor' under "Use new shortcut in:"
Assign a shortcut key that you like (ex: Ctrl + /) --> Assign --> Click Okay
If you want to uncomment then choose Edit.UncommentSelection and follow the step above, but it will need to be assigned to a different key other than Ctrl + /, may be use Ctrl+'
Step to change CommentSelection shortcut key

You are using SSMS, you can go to:
Tools - Options - Keyboard
JUST change keyboard mapping scheme to Vs Code
then Ctrl + / works
enter image description here

Documentation for how to comment out queries can be found Here.
But in short, press Ctrl + slash (/) together to toggle between commented/uncommented on highlight lines.
Ctrl + Shift + Slash can be used to comment/uncomment blocks of queries.

Related

Shortcut to Uppercase Selected Text in Oracle SQL Developer

I would like to highlight some text in a SQL Developer worksheet and convert it to uppercase with some keyboard shortcut.
Is there any such shortcut in Oracle SQL Developer?
I am using version 4.1.2.
Under Tools->Preferences->Shortcut Keys you can find and/or define the shortcut key combination for the Convert Selection to Uppercase and Convert Selection to Lowercase commands. I have mine mapped to CTRL+U and CTRL+L respectively. There unfortunately does not appear to be a specific command for converting text to Initcap, so the To Upper/Lower/Initcap command is the way to go for that. However, be aware that the To Upper/Lower/Initcap command actually cycles between five format modes:
UPPERCASE
lowercase
Initcap
Lower Keywords, Upper Identifiers
Upper Keywords, Lower Identifiers
Some of these modes will change the behavior of the code formatter (default key sequence CTRL+F7), and the Tools->Preferences->Code Editor->Completion Insight->Change case as you type setting if you have it enabled.
in 4.2.0.17 highlight the word(s) then Alt + '
This is perhaps and old question, but I noticed that while on Mac, the keyboard shortcut for cycle is unbound.
I followed the above suggestions in
tools->preferences->shortcuts
and bound it myself to ctrl + ' but note that in 4.2 on Mac by default this is unbound.
This cycles through Upper/Lower/Initcap in my SQL Developer version 18.2.0.183 Build 183.1748.
ALT + '
Ctrl + ' changes case by default. You can find all shortcuts in:
tools->preferences->shortcuts
Found it! You can select text in your worksheet, then use Ctrl+Shift+" to switch between cases (in version 4.1.2).
It will cycle between the following cases:
Upper Case:
SELECT * FROM MYSCHEMA.EXAMPLE;
Lower Case:
select * from myschema.example;
Upper Keywords:
SELECT * FROM myschema.example;
Lower Keywords, Upper Identifiers:
select * from MYSCHEMA.EXAMPLE;
Upper Keywords, Lower Identifiers:
SELECT * FROM myschema.example;
Initial Cap:
Select * From Myschema.Example;
As mentioned by #PiotrSiekierski, you can change the keyboard shortcuts in Tools -> Preferences -> Shortcut Keys. In version 4.1.2, the Ctrl+' shortcut is mapped to 'Navigate Down' by default.
As mentioned by #Sentinel, if you are not interested in cycling through the different case options, you can assign a shortcut to 'Convert Selection to Uppercase' or 'Convert Selection to Lowercase' by going to Tools -> Preferences -> Shorcut Keys and searching for the desired functionality. You can then assign a shortcut to those commands, such as Ctrl+U or Ctrl+L. In version 4.1.2, the 'Convert Selection to Uppercase' and 'Convert Selection to Lowercase' commands have no shortcut mapping by default.
This cycles through Upper/Lower/Initcap.
CTRL + '
Use
Control + '
Everytime you press it, it toggles between camel case, lower case, and upper case. I hope this helped you.
My SQL dev is 18.4. It worked for me
In newest versions you can highlight the text and then go to: Tools >> PL/SQL Beautifier and this will format your query and uppercase the text!
Hope it helps.
In sql server selected text Convert in to upper case and lower case use this shortcut key
Upper Case : ctr + shift + U
Lower Case : ctr + shift + L

Sublime Text editor: Is there a shortcut to select everything below this point and everything above this point

Is there a shortcut to select all code below a certain point and above a certain point, if it's not already preset what is the best way of developing one?
Ctrl+Shift+Home to select everything above.
Ctrl+Shift+End to select everything below.
Try Cmd + Shift + Up/Down or Ctrl + Shift + Up/Down on windows.
This will highlight / select all text above / below your current cursor location.

Is there any shortcut for CodeBlocks to format the code?

Is there any shortcut for CodeBlocks to format the code?
I haven't find any tip in google.
I found only "format use AStyle", but it come up with right mouse button only...
probably not by default but you should be able to assign it there:
Settings -> Editor -> Keyboard shortcuts -> Plugins -> Source code formatter (AStyle)
My favourite = Ctrl + A then Ctrl + Shift + F.
You (these are the default settings I believe) can select a block of code and press the Tab key. This will indent the entire block.
So for indenting a whole file: Ctrl + A, then Tab.
In addition, you can use Shift + Tab on a selected block to "unindent"
You can move through the open tabs with Ctrl + Shift + Tab.
As for the best shortcuts:
I like Ctrl + D to duplicate a line and
Ctrl + L to copy it.
Anyway, you can set whatever shortkeys you like in the Editor menu (there you will also be able to find all shortkey currently set).

ctrl + // to toggle "comment"

Is it possible to replace CtrlKC and CtrlKU to just Ctrl/?
I want to replace 2 hotkeys with 1 hotkey that "toggle" either text is commented or uncomented.
I.e. similar to Eclipse
I don't believe its possible to replace two hotkeys with 1 hotkey in visual studio. However you can create two hotkeys that are very similar in order to more easily toggle a comment.
An example would be:
Ctrl +
/ = Comment
Shift +
Ctrl +
/ = Uncomment
You can do this by going into the Tools -> Options menu.
Selecting "Keyboard" in the list box to the left.
Then type "comment" in the [Show commands containing:] textbox.
Assign your desired hot keys to:
Edit.CommentSelection
Edit.UncommentSelection
Hope that helps.

Is there a way to delete a line in Visual Studio without cutting it?

I want to delete a line just like hitting Ctrl + X without anything selected, but without saving the line to the copy stack. Is this possible?
I'm using Visual Studio 2010.
Edit.LineDelete is the name of the command. By default it's bound to Ctrl + Shift + L, but you can give it whatever you like in Tools | Options | Keyboard.
Edit: Corrected default shortcut info.
Ctrl + Shift + L will delete the line and not copy to the clipboard.
I mapped Ctrl + L (Global) to Edit.LineDelete. Otherwise, the shortcut key is Ctrl + Shift + L, which is awkward. Go to Tools > Options > Environment > Keyboard as shown below.
Correction in my answer
Ubuntu 16 &
Visual studio Version: 1.30.1
To cut line
Shift + del
To delete line Shift + Ctrl + k
CTRL + L (Visual Studio 2019 Windows)
Its Cmd + Shift + K on mac by default.
But it can be modified according to user needs from the settings (Preferences -> Keyboard Shortcuts) -> search for Delete Line key value.
Valid Answer By 2022 for VS Code (with image)
All the above answers regarding Ctrl + Shift + L are now deprecated.
The correct default behavior is Ctrl + Shift + K
(⌘ + Shift + K if you're a MAC user).
To change this default behavior:
1- Go to File > Preferences > Keyboard Shortcuts (OR click Ctr+K Ctrl+S)
2- Type in the search bar delete line
Here you will find the corresponding behavior. You can change it just by double-clicking on it and pressing any desired combination of keys on your keyboard (pay attention of conflicting shortcuts).
By default, if you are using the C# default profile, you can delete a line using Ctrl + Shift + L.
You can customize this using Tools->Customize. Select "Keyboard". Look for the command Edit.LineDelete to assign it to whichever keyboard shortcut you like.
Source
If you got here looking for an answer for Visual Studio Code the default shortcut is:
ctrl + shift + K for Windows
⌘ + shift + K for MacOS
However, you can change on File > Preferences > Keyboard shortcuts
{
"key": "ctrl+shift+delete",
"command": "editor.action.deleteLines",
"when": "editorTextFocus && !editorReadonly"
}
Source
none of the above answers worked for me. to delete a line in visual studio code use :shift+del
All the answers were helpful but didn't seem to work for me.
So I found the solution --> for Visual Studio 2017 (and certainly 2019):
Tools > Options > Environment > Keyboard > on the right pane select Edit.LineEdit.
Below there is a ComboBox Use new shortcut in: with Global written --> Change it to Text Editor.
On the right there is a Text input Press shortcut keys:, so use the shortcut of your choice.
Then click on Assign PushButton on the right (otherwise it won't be applied).
Finally > OK.
You can now open a .CPP file and use your shortcut to remove a line.
On Visual Studio 2019 for Mac, it's CTRL + K to cut the whole line by default.
Here is a url for the keyboard short cut reference for windows:
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
For windows: Ctrl + Shift + k
The other answers are specific to Visual Studio, which is what was requested by OP, however if anyone is looking for a more generalized way to do this for most Windows programs, you can also Triple-Click to select any block of text, then just press the Delete key. This works for any Windows text editors or TextBoxes, including password boxes, search boxes, browser web address boxes, etc. For text editors such as Visual Studio, a block of text is typically one line of code. Obviously you can do other things too, such as triple-click to select a line of code, then Ctrl-X, Ctrl-V to cut/paste, etc, or just triple-click and type over it to replace a line.

Resources