Edit commenting shortcut in jupyter on mac - python-3.x

I use a Mac with a German keyboard. The shortcut function in jupyter cmd + / does not comment out marked lines, however I would really like this function on a shortcut. The main reason for it not working is mainly because on a German keyboard you access / by pressing shift + 7. When pressing cmd + shift + 7 the help section from the mac top bar drops down. When pressing cmd + 7, nothing happens.
In jupyters help section I tried editing the shortcut, but the commenting shortcut was not listed in the editing section.
Has someone a solution for this?

Related

How to jump to file explorer in VS Code?

Using the VIM extension for VS Code is there a key command to jump to the explorer pane and then back to the work window?
I cannot find anything in the docs.
I'm hoping there is something like my Control+N binding for NERDTree which lets me open the file viewer, pick a file and then close it.
I am not familiar with NERDTree, but I think Ctrl+Shift+e does what you are asking in vs code. Alternatively Ctrl+p may be an alternative? You could look at
linux keyboard shortcut for more reference.
The link is also available in Help > Keyboard Shortcut Reference
EDIT: I'm adding the equivalent shortcut for Mac OS since it's different layout. However, I don't use Mac OS.. So I add this without being able to confirm :
Shift+Command+E
Mac OS Keyboard shortcut for VS Code
Windows keyboard shortcuts are very similar to linux ones. So, I'll just include the link to windows shortcuts doc here. Windows Keyboard shortcut for VS Code
Just my two cents:
If you are using the Vim extension for VS code you can add this to your settings.json file:
"vim.normalModeKeyBindings": [
{
"before" : ["<leader>","a"],
"commands" : [
"workbench.view.explorer"
]
}
]
The exemple above uses <leader> + a while in normal mode to display the file explorer where you can navigate the file list with j and k. Pressing ENTER will open the file under the cursor and close the file list.
To set up a leader key just add in your settings.json:
"vim.leader" : "," ,
In addition to Santiago's comment, you're able to open a file in a new tab from the explorer (Cmd + Shift + E) with Ctrl + Enter for MacOS. I'm not sure about Windows or Linux.
If you want to go to a file with VIM in VSCode:
Enter Normal Mode (Esc)
Place cursor over file you want to jump to, e.g. between the quotes - "../models/postMessage.js";
Press lowercase gd - Go to definition

Ubuntu 16.04 Sublime Text 3 Command Palette and Enter key Completion not working

I already reinstall sublime text 3 many times but it wont fix my command palette. When i press Ctrl + Shift + P it open the Command Palette but if i try to type something the Palette will close. I want it to be the same with my other laptop, that if i Ctrl + Shift + P and type something then some hints will show and if i press enter it will trigger auto complete.
I already solve the problem just turning the numlock off. here's the answer source link

A keyboard shortcut to comment/uncomment the select text in Android Studio

How do I comment out several lines of text selected in the IDE with a control key combination?
I thought that Ctrl + Alt + C was the correct sequence, but that's not working.
To comment/uncomment one line, use: Ctrl + /.
To comment/uncomment a block, use: Ctrl + Shift + /.
MAC QWERTY (US- keyboard layout) without numpad:
Line comment : ⌘ + /
Block comment: ⌘ + ⌥ + /
MAC QWERTZ (e.g. German keyboard layout):
Android Studio Version ≥ 3.2:
Line comment : ⌘ + Numpad /
Block comment: ⌘ + ⌥ + Numpad /
thx #Manuel
Android Studio Version ≤ 3.0:
Line comment : ⌘ + -
Block comment: ⌘ + Shift + -
From menu, Code -> Comment with Line Commment. So simple.
Or, alternatively, add a shortcut as the following:
I had the same problem, usually, you have found the shortcut but it doesn't work because you have not a NumPad.
Actually, the only one issue I found is to set my own shortcut with the one I suppose should works.
First step, find the IDE shortcuts : cmd + shift + A enter shortcuts
Second step : Find Comments Shortcut with the finder
Third step : Set your custom shortcut (I suggest cmd + shift + / or cmd + : )
Now enjoy, it works on a macBook without NumPad
edit : cmd + shift + : has conflicts
Edit : this both works without conflicts
Issue on MacBook
At least in Android Studio 2.2.3 with default key mapping, to comment or uncomment a select text, same hotkeys are used as Toggle. Using the hotkeys changes the state from comment to uncomment, and next time Uncomment to comment on next and vice versa.
1. Comment / uncomment a block of code
Comment sample: /* --- Code block ---- */
Hotkey: Ctrl + Shift + "/"
Using the same key combinations again will "toggle" commenting or uncommenting the selection.
2. Comment / uncomment a line of code
Comment sample: // -- Code ---
Hotkey: Ctrl + "/"
Using the same key combinations again will "toggle" commenting or uncommenting the selection.
Note: Key mapping can be changed to different schemes like eclipse, visual studio... or to the custom hotkeys in File -> Settings -> Keymap
On Mac you need cmd + / to comment and uncomment.
if you are findind keyboard shortcuts for Fix doc comment like this:
/**
* ...
*/
you can do it by useing Live Template(setting - editor - Live Templates - add)
/**
* $comment$
*/
You can also use regions. See https://www.myandroidsolutions.com/2014/06/21/android-studio-intellij-idea-code-regions/
Select a block of code, then press Code > Surround With... (Ctrl + Alt + T) and select "region...endregion Comments" (2).
Windows 10 and Android Studio: Ctrl + / (on small num pad), don't use Ctrl + Shift-7!
Default shortcuts is under Preferences -> Keymap -> Main Menu -> Code menu
Add a shortcut for a single line comment (e.g. Ctrl+ ...)
Add a shortcut for a block comment (e.g. Ctrl+...)
You can use default one or customize it by right click

Code formatting shortcuts in Android Studio for Operation Systems

I have started developing with Android Studio. In Eclipse I was using Ctrl + Shift + F, but in Android Studio it does not work. It will be different.
How can I jump to any method in a .java file? I was using Ctrl + O in Eclipse.
Is it available? What is the shortcut for code formatting?
Windows: Ctrl + Alt + L
Linux: Ctrl + Shift + Alt + L
macOS: Option + Command + L
Reference: Key Commands and here are all of the commands for Windows/ Linux users and for Mac users.
As Rohit faced a problem in Ubuntu with the format code shortcut, this is due to the Ctrl + Alt + L key being used to lock the screen in Ubuntu.
I found that Ubuntu handles this keyboard shortcut first. So you should bind the Ctrl + Alt + L keyboard shortcut to something else so that it doesn't conflict with Ubuntu.
Steps
Go to System Tools → System Settings → Keyboard → Shortcuts tab → System → Lock Screen.
Select the row New Accelerator..., then press any special key with the Alpha key (e.g. Shift + L). You should've successfully changed the keyboard shortcut.
Check if the keyboard shortcut now works in Android Studio.
Alternative method
Ctrl + Alt + Shift + L (to show a dialog)
You can also use Eclipse shortcuts.
Windows and Linux: Go to menu File → Settings → Keymap
macOS: Go to menu Preferences → Keymap and choose Eclipse from the drop-down menu.
Using MenuBar
Select code which you want to reformat
Click on Code in the menu bar and select Reformat Code as shown in the image below:
In Android studio 3.5, there is problem with rearranging the xml code, it also rearrange the views as well, so need to use these settings first.
Settings -> Editor -> Code Style -> XML-> Set From -> Predefined Style > Android.
Update for Android Studio 4+
Since Android Studio 4+, you might face issue shortcuts on mac. Shortcuts not working after updating to Android studio 4, in Mac? have an answer for that.
You can also use Eclipse's keyboard shortcuts: just go to menu Preferences → keymap and choose Eclipse from the dropdown menu.
The actual path is: menu File → Settings → Keymap (under IDE settings)
Check Keyboard Commands given in the Android Studio Tips & Trick documentation:
Just select the code and
on Windows do Ctrl + Alt + L
on Linux do Ctrl + Super + Alt + L
on Mac do CMD + Alt + L
This solution from junaidp
For formatting code in Android Studio on Linux you could instead use Ctrl + Alt + Super + L. You could use this and avoid having to change the system shortcut. (Super key is the Windows icon key besides the Alt key).
For code formatting in Android Studio:
Ctrl + Alt + L (Windows/Linux)
Option + Cmd + L (Mac)
The user can also use Eclipse's keyboard shortcuts: just go on menu Setting → Preferences → Keymap and choose Eclipse (or any one you like) from the dropdown menu.
You will have to apply all Eclipse shortcuts with Android Studio before using all those shortcuts.
Procedure:
Steps:
Setting -> KeyMap -> Select Eclipse -> Apply -> OK
Now you can use all Eclipse shortcuts in Android Studio...
Have some snapshots here.
Check this. Also you can change it as per your preference.
For auto formatting your Java/XML files in Android Studio, use following commands:
As you are looking for a single point to go with your work as Eclipse did, there is no such built-in functionality in Android Studio, but it gives you the ability to do it through a macro. Follow these steps:
In Android Studio, open any of your source code files.
Press Ctrl + Alt + O This is used to find/optimize unused import.
If a dialog open select "Don't show it again" and hit Run.
Go to Edit > Macros > Start Macro Recording.
Press Ctrl + Alt + O.
Press Ctrl + Alt + L. This formats your code. (Shift+Ctrl+Alt+L for Ubuntu).
Press Ctrl + S. This saves your file;)
Go to Edit > Macros > Stop Macro Recording.
Save this created macro with a name, for instance: “Auto Formatting".
Boom, you have now successfully created your macro. Now just add/assign a shortcut to it:
Open Preferences.
Search in the left bar for Keymap.
In the right hand pane, click in the search bar and type the name of your saved macro ("Auto Formatting".)
Double click on your item. There might be two, it doesn’t matter which one you click on.
Click Add Keyboard Shortcut.
Set your keyboard shortcut to Ctrl + S.
Finally, confirm overriding Ctrl + S to be your new macro.
Just to add to #user2340612 answer to switch keymaps to Eclipse, the path for Android Studio 1.0.1 is:
Menu File → Settings → Keymap (under the Editor option) → Keymaps = Eclipse
Ctrl+Alt+L might conflict with Lock Screen shortcut in Ubuntu. In such case you can change the keyboard shortcut for Reformatting Code as follows:
File-> Settings-> IDE Settings-> Keymap
Search for Reformat Code and change the keyboard shortcut.
Really, I went to this thread because of my Ubuntu locks screen after this shortcut Ctrl + Alt + L. So if you are have the same problem just go to the Settings - Keyboard - Shortcuts - System and change the default shortcut for the "Lock screen".
In addition to auto-formatting that the other answers describe, another trick is to highlight the text that you want to indent and then press
Tab to increase the indent or
Shift+Tab to decrease the indent.
Check out the Keyboard Shortcut docs for more.
For those who are wondering about the alignment issue inside bracket, JetBrains has this as in their issue tracking.
Here is the answer:
How do I align/format code in Android Studio?
I think is clear that for code formatting in Android Studio the combination keys are:
CTRL + ALT + L (Win/ Linux)
OPTION + CMD + L (Mac)
However, we forgot to answer about the Jumping into the method.
Well to go into any declaration/implementation there three ways:
Goto Declaration
CTRL + B or CTRL + CLICK (Win/ Linux)
CMD + B or CMD + CLICK (Mac)
Goto Implementation
These commands show a list of all the classes/interfaces that are implementing the selected class/interface. On variables, it has the same effect as Goto Declaration.
CTRL + ALT + B (Win/ Linux)
CMD + ALT + B (Mac)
Goto Type Declaration
These shortcuts will go into the declaration of the “AnyClass” class.
CTRL + SHIFT + B (Win/ Linux)
CTRL + SHIFT + B (Mac)
Additionally, there is a shortcut for Goto the Super Class. This will open the parent of the current symbol. Pretty much the opposite of Goto Implementation. For overridden methods, it will open its parent implementation.
CTRL + U (Win/ Linux)
CMD + U (Mac)
The shortcut that worked for me is
SHIFT+ALT+CMD+L
You can optimize imports to remove the ones you don't use, and auto import the new classes.
If you are using the Dart plugin, go to Android Studio, menu File -> Settings.
And search for "reformat code with", click "Reformat code with dartfmt" under the main menu:
Click "Add keyboard Shortcut".
Then press Ctrl + Alt + L and the shortcut should work (If Ctrl + Alt + L make the computer sleep/suspend, change the shortcut in your system settings to something else. Otherwise, both shortcuts will collide).
Some times even I type Ctrl+Alt+L is not working in XML, so found this way to make it work.
Go to Settings --> Editor --> Code Style --> Select Default --> Ok.
For your reference see the screenshot:
Try this.
On Windows do Ctrl + Alt + L
On Linux do Ctrl + Shift + Alt + L for dialog to open and then reformat.
On Mac do CMD + Alt + L
Note: Here many answers for Linux is just Ctrl + Alt + L
which is wrong. In Linux, doing Ctrl + Alt + L locks the system.
It's Ctrl + Alt + L for Windows.
For a complete list of keyboard shortcuts please take a look at the user manual: https://developer.android.com/studio/intro/keyboard-shortcuts.html
There are some shortcut keys for rearrange or reformat code in Android studio.
Linux: Ctrl + Shift + Alt + L
mac OS: Option + Command + L
Windows: Ctrl + Alt + L
I have had an experience using Ctrl + Alt + L in Windows that this shortcut did not work at all because it was reserved by another software, running at the background; which I realized later.
I decided to mention this issue as I thought it may be helpful . . .
You can use the following shortcut for code formatting:
Ctrl+Alt+L
The best key where you can find all commands in Eclipse is Ctrl + Shift + L.
By pressing this you can get all the commands in Eclipse.
One important is Ctrl + Shift + O to import and un-import useless imports.

How to paste into a terminal?

I have copied a URL, such as git://gitorious.org/openhatch/oh-mainline.git. I want to paste this in the terminal using a keyboard shortcut.
Please don't say "right click and paste."
Gnome terminal defaults to ControlShiftv
OSX terminal defaults to Commandv. You can also use CommandControlv to paste the text in escaped form.
Windows 7 terminal defaults to CtrlShiftInsert
Shift + Insert usually works throughout X11.
Mostly likely middle click your mouse.
Or try Shift + Insert.
It all depends on terminal used and X11-config for mouse.
same for Terminator
Ctrl + Shift + V
Look at your terminal key-bindings if any if that doesn't work
In Konsole (KDE terminal) is the same, Ctrl + Shift + V
On windows 7:
Ctrl + Shift + Ins
works for me!
Like this article How to copy paste text and commands in the Linux terminal mentioned.
You can use middle mouse button to implement the functionality of paste. I tested it on terminal successfully.

Resources