Is it possible to do block-comments in Google Colab? - google-colaboratory

In Jupyter Notebook, you can toggle/comment a block of selected code with Ctrl + /, but this doesn't work in Google Colaboratory notebooks. Is there a way to comment out several lines of Python code easily in a Colaboratory notebook?
I've looked in the documentation, but I came up short.

In the default Colab keyboard shortcuts, you can block comment text using Ctrl+/.
If this does not work for you, check Tools->Keyboard Shortcuts and search for "Comment Current Line" to see what the shortcut is within your current settings.

You can select the lines of code and press (Ctrl + /) to comment or uncomment your selected lines of code.
You can also use triple single quotes (''') at the start and end of the code block you are interested to comment out.
''' ...Your commented code... '''

If you are a Mac user, you can use Command + / for commenting out, and if you want to uncomment again, select the lines and then Command + /.

For Mac users who don't have an American keyboard like me: it seems like Colab thinks you are using an American keyboard for shortcuts, and so to make the '/' character you have to press the second button to the right of the 'm'. I'll leave an image to explain.
My keyboard looks like this:
As I said, I have to press the . key to make '/' as if I were using an American keyboard.

For Mac users:
first select the lines that you want to comment
second push these buttons: Command + Ctrl + Shift + /
Especially in the Italian keyboard it would be: Command + Ctrl + Shift + 7 (because the "/" character is combined with button "7")

For some reason, I need to do Ctrl + Shift + :.
Which technically is Ctrl + /.
(I use an AZERTYUIOP keyboard.)

if you come here with an Italian keyboard you should press:
command + control + .

When using Mac the keyboard shortcut is ⌘+/.
Note that depending on your layout, / cannot be directly addressed and its combination is different when combined with ⌘. For example, on a German keyboard / is [Shift]+7 but the combination ⌘+/ is ⌘+[Shift]+ß.
When you are unsure about which combination is correct, use the inbuilt keyboard viewer which provides a live view of the meaning of keys while selecting modifiers.
Keyboard Viewer: default keyboard mapping
Keyboard Viewer: modifier keys keyboard mapping

Related

Toggle Comments Keyboard Shortcut (CTRL + /) Does Not Work

I use SAS Enterprise Guide and Teradata Studio Express to code for my day job. WindowsOS.
I use CTRL + / shortcut to comment lines of code out in both apps. Suddenly, this shortcut has stopped working. I've checked all my keyboard and Code Shortcut Key settings in both apps and nothing seems out of place!
All other shortcuts seem to work in both apps, common ones I use like CTRL+C (copy), CTRL+X (cut), CTRL+V (paste) etc
I've got no idea why the 'comment out' shortcut is unable to register. Anyone else encounter this same annoying issue?
CTRL + : will pack your line in /* and */
If you have selected a range, Enterprise Guide will do that with every line from which you selected any character.
CTRL + Shift + : will unpack them
You just have to define it again.
Go to Tools-->options-->Enhanced Editor Keys
Select the Command "Comment the selection...." and press Assign keys
within "Press new shortcut key:" enter the ctrl + : key and press assign

Is there a shortcut to go to the beginning/end of a file in IntelliJ?

I often need to get quickly to the very beginning or very end of a file in the IntelliJ editor. Is there a shortcut key or button that allows me to do this quickly?
I am running on Windows, if that matters.
Beginning of File: Fn + ⌘ + ←
End of File: Fn + ⌘ + →
Note: This answer was posted prior to windows specificity. Leaving it here to include MacOS alternative.
On Windows, you can use Ctrl+Home and Ctrl+End to go to the beginning and end of a file respectively.
The action is called Move caret to Page Top/Bottom, default shortcuts would depend on the OS/Keymap and can be checked here:
On Windows these are Ctrl+Page Up and Ctrl+Page Down.
To find what keyboard strokes are already defined for this, go to Preferences->Keymap and search for text start for jumping to the beginning of the file and text end for jumping to the end of the file. You'll get something that looks like this:
The right column tells you what keystrokes have been mapped to these functions. Feel free to change them to something that you find more intuitive by double clicking on the right column and following the instructions on the pop-ups.
Under preferences -> Keymap, a shortcut for Scroll to Bottomand Scroll to Top can be set.
By default, they are not assigned.
By default in windows the shortcut is
ctrl+end
You can customize the shortcut. To use only end button as shortcut go to Settings -> Keymap -> Editor action -> move caret to text end
Right click on move caret to text end and update shortcut to end
On a Mac, these following keys:
to start of the file:
option + command + [
to end of the file:
option + command + ]
After spending minutes to search on the web, i don't find the answer for just using cmd + up or down. If you are the same, as a quick workaround, you can cmd + a to select all text and press up or down to move it.

IntelliJ shortcut to comment line

There is a way in webstorm to comment or uncomment a specific line or selected block of source code with shortcut?
I try to use CTRL + / but doesn't work for me
References
https://www.jetbrains.com/help/idea/mastering-keyboard-shortcuts.html
Try to use Ctrl+Slash or Ctrl+Shift+Slash for block comment
If this doesn't work show in your Setting -> Keymap -> Search comment
Use CTRL+/, but with the / located on the numpad.
The question remains why commenting with / (the one besides .) does not work (it does not for me, either).
Ctrl + / ==> To comment/uncomment a line .
Ctrl + Shift + / ==> To comment/uncomment block of code.
Ctrl + Y ==> To delete a line.
On a Mac with an extra keyboard it is CMD + Numpad's /.
The one on the native Macbook keyboard I did not get to work.
Check this post as well: Intellij comment shortcut opens help tab on the Mac menu bar
On Windows with a German keyboard layoout the default keyboard shortcut for the comment lines action Ctrl+/ conflicts with the bookmark shortcut Ctrl+7. You need to remove the keyboard shortcut for bookmarks in order to get this to work.
#Note Shortcut IntelliJ IDEA
Ctrl + / => comment or uncomment a line -> //
Ctrl + shift + / => comment or uncomment block of code -> /**/
Ctrl + y => delete a line
Ctrl + d => duplicate a line
If Ctrl + Shift + / doesn't work , try Ctrl + Shift + Num Pad /.
You can check the exact configuration in settings->keymap.
Commenting out each line of selected code for Mac users without numpad would have to add a keyboard shortcut:
Navigate to settings: Preferences > Keymap > Main menu > Code
Double click on Comment with Line Comment
Insert your shortcut, for example: cmd + shift + 7 would be interpreted as shift + cmd + 7 but works the same.
I have an AZERTY keypad in French, so this was the answer for me :
Ctrl + Shift + / on the numpad
Because / out of the numpad was detected as :, even with Caps Lock on.
You can check how the keystrokes are actually detected by IntelliJ in :
On Windows :
Settings > Keymap > click on the icon of Magnifying glass with cubes (tooltip is "Find Actions By Shortcut"). In the little tooltip that opens, you stroke the keys and observe the registered results.
On Ubuntu :
Settings > Keymap > click on the icon of Keyboard, right next to the search input (tooltip is "Find Actions By Shortcut"). In the little tooltip that opens, you stroke the keys and observe the registered results.
You need to activate this option:
'Settings' > 'Keymap' > 'Use national layouts for shortcuts (requires restart)'
As said before on Mac Montery 12
on Idea 2020.3
CMD + NumPad /
or from Action dialog:
It is necessary to switch to the English layout
its possible to use inellij IDEA by the way you customized before with an IDE like VisualStudio
Settings -> KeyMap -> Choose your old IDE its a grate! feature life saver :)
try ctrl + shift + 7 or num lock and then ctrl + /
control + / (this is the mathematical one which is located on the numbad)

What is the shortcut in IntelliJ IDEA to find method / functions?

I know that Ctrl + N is to find classes and it is very useful. But what about methods?
ctrl + F12 (cmd + F12 on macOS) will show all members of the current class in a popup window and let you pick up one. It works exactly like the ctrl + o shortcut in eclipse, much faster than ctrl + alt + shift + n
Windows : ^ ctrl + F12
MacOS : ⌘ cmd + F12
Above commands will show the functions/methods in the current class.
Press ⇧ SHIFT TWO times if you want to search both class and method in the whole project.
Ctrl + Alt + Shift + N allows you to search for symbols, including methods.
The primary advantage of this more complicated keybinding is that is searches in all files, not just the current file as Ctrl + F12 does.
(And as always, for Mac you substitute Cmd for Ctrl for these keybindings.)
Android Studio on Mac
Command + Option + O
Opens up the Symbol lookup that you can jump to most of the methods/functions in your currently opened document.
Intellij IDEA 2017.3.4 - 2018.2 (Ultimate) on OSX
CMD + fn + F12
will show all members of the current class in a popup window, then you can search method in that class.
BUT, this answer is depends on your Keyboard setting. If your keyboard setting in
System Preferences > Keyboard > Use all F1, F2, etc. keys as standard function keys
is selected, then the shortcut becomes
CMD + F12
CTRL + F12 brings up the File Structure navigation menu, which lets you search for members of the currently open file.
IntelliJ IDEA Version 12.13 Ultimate Edition:
Macs:
command + option + shift + N
or on Menu -> Navigate > Symbol ...
Slightly beside the actual question, but nonetheless useful: The Help menu of Intellij has an option 'Default Keymap reference', which opens a PDF with the complete mapping. (Ctrl+F12 is mentioned there)
If you just want to look for methods:
On mac OS X 10.5+ binding, it is Alt + ⌘ + O
By Default XWin Key binding, it is Shift + Ctrl + Alt + N
You can also press double SHIFT then, you can search anything (not only method, but also class, files, and actions)
It is worth adding that if you want to search for a method of a class, you can use a . (dot) between the class and method name inside of either the search everywhere or search symbols dialog. This even works with IDEAs usual search benefits. For example, you can search for LDT.now and LocalDateTime::now will pop up as a result. (As long as you are searching All Files and not just Project Files).
If you click on a method, you can do Ctrl + B to go to that method's declaration. Similar to F12 in MS Visual Studio.
To Find the actions build in the IDEA(reindent, create new, ...) you can use
CRTL+SHIFT+A
then type indent for example and ENTER.
If I need navigate to method in currently opened class, I use this combination: ALT+7 (CMD+7 on Mac) to open structure view, and press two times (first time open, second time focus on view), type name of methods, select on of needed.
Intellij v 13.1.4, OSX
The Open Symbol keyboard shortcut is
command+shift+s
Ctrl + Shift + Alt+ 7 after selecting the method
I tried SHIFT + SHIFT and ALT + CMD + O
But I think the most powerful and easy to use feature is find in all files CMD + SHIFT + F.
Choose regex and write .*partOfMethodName.*\( and it shows all places and can see the actual source code in place without going to that specific file.

How to Select Columns in Editors (Atom,Notepad++, Kate, VIM, Sublime, Textpad,etc) and IDEs (NetBeans, IntelliJ IDEA, Eclipse, Visual Studio, etc) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Closed 1 year ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
How to select columns in Editors and IDEs to columnar delete, insert or replace some characters ?
Editors:
Atom
Notepad++
Kate
VIM
Sublime
Emacs
Textpad
Emerald Editor
UltraEdit
MCEdit
jEdit
Nedit
IDEs:
NetBeans
Eclipse
Visual Studio
IntelliJ IDEA
Flash Builder
Aptana Studio
Notepad++, Visual Studio, and some others: Alt + drag.
vim: Ctrl + v or (bizarrely enough) Quad-click-drag. In windows: Ctrl + Q (since Ctrl + V is the standard for paste)
In Kate toggle Ctrl + shift + B .
In Netbeans 7.1 can select columns (Rectangular Selection) with Ctrl + shift + R . There is also a button in the code editor available.
This is how rectangular selections look like:
Eclipse used to need a column mode plugin to be able to select a rectangular selection.
Since Eclipse 3.5, you just need to type Alt+Shift+A: see its News and Noteworthy section. (On OS X it's Option-Command-A.)
Or activate the 'Editor Presentation' action set ( Window > Customize Perspective menu) to get a tool bar button for toggling the block selection mode.
AmbroseChapel adds in the comments:
This is a toggle.
Columnar selection is a mode you enter and leave: in other words, Eclipse switches into a mode where all mouse selections have to be columnar and you stay in that mode until you switch back (by using the same command again).
It's not like other editors where columnar selections are enabled only while certain keys are down.
In vim column visual mode is Ctrl + v. If that is what you meant?
SublimeText 2, 3, and 4
Using the Mouse
Different mouse buttons are used on each platform:
OS X
Left Mouse Button + Option
OR: Middle Mouse Button
Add to selection: Command
Subtract from selection: Command+Shift
Windows
Right Mouse Button + Shift
OR: Middle Mouse Button
Add to selection: Ctrl
Subtract from selection: Alt
Linux
Right Mouse Button + Shift
Add to selection: Ctrl
Subtract from selection: Alt
Using the Keyboard
OS X
ctrl + shift + ↑
ctrl + shift + ↓
Windows
ctrl + alt + ↑
ctrl + alt + ↓
Linux
ctrl + alt + ↑
ctrl + alt + ↓
Source: SublimeText2 Documentation
You didn't explicitly state emacs, but since you've highlighted lots of editors...
In emacs, you can use rectangles for this, where a column is a rectangle of width 1.
To create a rectangle, mark the top-left and bottom-right of the rectangle (where the bottom-right mark is one to the right of the further right point included in the rectangle. You can then manipulate via:
C-x r k
Kill the text of the region-rectangle, saving its contents as the "last killed rectangle" (kill-rectangle).
C-x r d
Delete the text of the region-rectangle (delete-rectangle).
C-x r y
Yank the last killed rectangle with its upper left corner at point (yank-rectangle).
C-x r o
Insert blank space to fill the space of the region-rectangle (open-rectangle). This pushes the previous contents of the region-rectangle rightward.
M-x clear-rectangle
Clear the region-rectangle by replacing its contents with spaces.
M-x delete-whitespace-rectangle
Delete whitespace in each of the lines on the specified rectangle, starting from the left edge column of the rectangle.
C-x r t string RET
Replace rectangle contents with string on each line. (string-rectangle).
M-x string-insert-rectangle RET string RET
Insert string on each line of the rectangle.
In IntelliJ IDEA, you can switch the selection mode with Alt + Shift + Insert combination. You can also column select by keeping the middle mouse button (i.e. the scroll wheel button) pressed and dragging.
on Kate
Ctrl + Shift + B also allows you to add more columns by simply clicking anywhere and paste it.
I used this when saving text files I copied from Google Translate as a side-by-side view.
This feature is not available in older versions of Netbeans (up to 7.1) and the plugin is not supported anymore.
A plugin is now available for NetBeans 6.9.
In TextMate with the mouse: start a selection and keep alt pressed while you move the cursor.
Without the mouse: first select normally using ⇧ and arrows then hit alt and move the cursor.
in Notepad++ , you can select a particular column holding ctrl + alt + shift and then left click mouse button and drag to select.
In TextPad:
With the mouse, Left-Click + Alt + Drag. Note that if you first use Alt, and then Click-and-drag, it does not work (at least for me). Ctrl+Alt instead of Alt also Works.
For pure keyboard, no mouse, enable Block Select Mode with Ctrl+Q, B.
Or use the sequence Alt, C, B, to do it via the Configure menu.
Warning 1: if Word Wrap is enabled, then Block Select Mode will not be available (which is somewhat logical). First disable Word Wrap. This was causing me some trouble, and this gave me the answer.
Warning 2: if you mean to insert text in every selected row by typing, you have to use Edit, Fill Block. Other editors let you type in directly.
In Ultra Edit and Crimson (or Emerald) Editor you can enable/disable the column mode with Alt + C
In textpad.
Go to left top of the page.
hold "shift key
Now use right arrow key to select column.
Now click "down arrow" key.
And the entire column will be selected.
jEdit:
With the keyboard: press Alt-\ (Opt-\ in Mac OS X) to toggle between rectangular and normal selection mode; then use Shift plus arrow keys to extend selection. You can switch back to regular selection mode with another Alt-\ (Opt-\ in Mac OS X), if desired.
With the mouse: Either use Alt-\ (Opt-\ in Mac OS X) as above to toggle rectangular selection mode, then drag as usual; or Ctrl-drag (Cmd-drag in Mac OS X). You can switch back to regular selection mode with another Alt-\ (Opt-\ in Mac OS X), if desired.
Actually, you can even make a non-rectangular selection the normal way and then hit Alt-\ (Opt-\ in Mac OS X) to convert it into a rectangular one.
In MCEdit toggle Shift+F3 (ie F13) or F9->Edit ->Mark columns.
P.S. In this case, MCEdit is an editor written for the Midnight Commander.
In Sublime3 (Windows):
Some users may get an inverted screen using the Ctrl+Alt+▲ in windows. To Solve this go to
Preferences->Key Bindings-User
And add these two lines at the end of the file just before closing brackets:
{ "keys": ["ctrl+alt+pageup"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+alt+pagedown"], "command": "select_lines", "args": {"forward": true} }
Or use your own keys.
If you're using Nedit under Cygwin-X (or any platform for that matter), hold down the Ctrl key while selecting text with the left mouse.
Additionally, you can then drag the selected "box" around in an insert mode using the depressed left-mouse button or in overwrite mode by using Ctrl+left-mouse button.
With Nedit you can do several operations with selected column:
CTRL+LEFT-MOUSE -> Mark Rectangular Text-Area
MIDDLE-MOUSE pressed in area -> moving text area with pushing aside other text
CTRL+MIDDLE-MOUSE pressed in marked area -> moving text area with overriding aside text and deleting text from original position
CTRL+SHIFT+MIDDLE-MOUSE pressed in marked area -> copying text area with overriding aside text and keeping text from original position
In Flash Builder (v 4.5 and up), and Aptana Studio (at least v 2.0.5) there is a toolbar button to toggle block select. It is between the 'mark occurrences' and 'show whitespace characters' buttons. There is also a Alt + Shift + A shortcut. Not surprisingly, this is basically the same as for Eclipse, but I'm including here for completeness.
For any editor, you can use the below shortcuts. These shortcuts work for every text area also.
Shift + UpArrow/DownArrow - this will select text line by line
Ctrl + Shift + LeftArrow/RightArrow - this will select text word by word
Ctrl + BackSpace - this will delete text word by word