How to get emacs-like keybindings in Pharo? - keyboard-shortcuts

I've downloaded Pharo today, and I noticed most keybindings don't work within the language environment.
Is there any possible way to get standard Mac / Linux keybindings to work?
I could find no answer searching on Google.
I'd appreciate if someone could tell me how to configure the standard
Ctrl+a, BeginningOfLine
Ctrl+e, EndOfLine
Ctrl+d, forwardDelete
Ctrl+f, forwardChar
Ctrl+b, backwardChar
Ctrl+n, nextLine
Ctrl+p, previousLine
to work on Pharo 5.0.

If by "standard" you mean "emacs-like keybindings" then no, Pharo does not support such scheme nor is there an easy way to change them.
You could change some of the hard-coded shortcuts in places like the PharoShortcuts and RubSmalltalkEditor class>>buildShortcutsOn: (which powers the Playground).
However there are very likely more places (e.g. Nautilus).
Several of the shortcuts you mentioned are also core shortcuts for Pharo (in the sense that you can execute them pretty much anywhere you can type text), namely:
ctrl+p for printing the selection
ctrl+d for doing (executing) the selection
ctrl+n browsing senders of the highlighted selector
Furthermore ctrl+a is "select all" as in pretty much every text editor, and ctrl+f find.
However, there is an ongoing effort to cleanup the shortcuts and unify them into single place (PharoShortcuts), so in time such change should easily be possible.

To get the basic emacs-style cursor navigation on my Mac, I punted with BetterTouchTool to send Pharo keys, like this:
ctrl+a --> fn + left-arrow Beginning of line
ctrl+e --> fn + right-arrow End of line
ctrl+p --> up-arrow Previous line
ctrl+n --> down-arrow Next line
ctrl+f --> right-arrow Forward character
ctrl+b --> left arrow Backward character
ctrl+v --> fn + down-arrow Next page (behavior is inconsistent)
option+v --> fn + up-arrow Previous page (also inconsistent)
It's not ideal, but a big step in the right direction. BetterTouchTool is awesomeness that any Mac power user should seriously consider anyway.
For the benefit of non-Mac users, there is no collision with Pharo core shortcut keys in this scheme, because on the Mac the Command key is used in place of Ctrl for Pharo core shortcuts.

Related

Line-Comment shortcut on german keyboards

What is the equivalent of CTRL + SLASH on german keyboards?
I know that US-Layouts got that / where the german _ is, since I used an US-Layout for some time. But CTRL + _ just collapses a method.
Just use the slash (Ctrl + /) on the numpad.
I found a solution for using the desired shortcut on Intellij Idea.
You just need to:
- click Ctrl+Alt+S to open the settings dialog box,
- choose "Keymap" from the left menu
- then search for keyword "comment".
- right click on "Comment with Block comment" and select add Keyboar Shortcuts.
- Type the shortcut you want to use and click ok.
For more details : https://www.jetbrains.com/help/idea/2016.3/configuring-keyboard-shortcuts.html
I just changed Ctrl + Slash and Ctrl + Shift + Slash to Ctrl + 7 and Ctrl + Shift + 7.
Works as expected, as they are the same key on german keyboards.
Problem is Ctrl + Shift + 7 is used for bookmarking a line, so I have to override this shortcut.
As of today it is still an unresolved IDEA issue, see this
https://youtrack.jetbrains.com/issue/IDEA-16116.
Defining a custom keymap seems to be the best solution.
A little late to the party, but maybe it helps someone...
I'm using Ubuntu 16.04 with the gnome desktop.
I frequently switch between the german and english keyboard layout.
In order to be able to use IntelliJ shortcuts with the english layout I had to change the order of the layouts in my system settings:
(gnome desktop) > settings > keyboard > Input source (top right corner)
There you find all configured input sources. I moved "english" to the top.
Now I can use all shortcuts based on the english layout, even when I switch to german. This means e.g. Ctrl + _ with the german or Ctrl + / with english layout would be line-comment in IntelliJ.
Not really an answer but I found this while googling and unfortunately had to add a custom keymap, too.
I now have it on CMD + ß. The combination is not used (which makes sense due to its QWERTZ relation). Works for me.
I just discovered that STRG(CTRL) + # works for my QWERTZ-Keyboard.
Hope it helps somebody!
It's been almost 4.5 years and I just want to share with you guys, which route I took because of only this issue (more or less). Sorry that this is not an answer in the proper stackoverflow manner.
I switched my keyboard setting to "US - International" and only use this one for everything I do nowadays. You can have the umlauts (by pressing Shift + ä and then your desired letter) on windows and macos. An all the "special keys" feel so much more natural! While you have to do finger-splits for certain characters, they use AT MAX the shift key on US layouts. Feels so much nicer to write and code like that!
I know, this is probably not what you are going to do, but I can tell you, that I find more and more people who did that and not a single one of them regretted that. Obviously that means, that you should be able to type blindly. :) At least, most keyboard I use, don't have the US layout on it. I adapted to it pretty fast though.
So basically, having the umlauts takes a tiny little bit more effort, but this is really worth it, because everything else makes so much sense on the US layout and you will get all the keymaps as they were intended to be used. Not those crappy "translations" that sometimes don't make sense, like this annoying line-comment thingy here.
Update 2021:
Compare how you write those characters on a US layout compared to whichever layout you are using. There are dramatically less keys involved in using those chars and I can write them faster and also with less wear and tear on my fingers.
;
:
/
`
'
#
<>
[]
{}
I also struggle with this shortcut and could'nt find the right combination.
The only solution i found is to change to English keybord layout using Alt+Shift and then use Strg+Underscore for commenting and back to german layout Alt+Shift.
This helps for the moment. Hope for a better solution.
I solved this by changing the shortcut. You can do this the following way:
In Android Studio in the top menu, click on Android
Studio->Preferences...
A new window pops up, in the side menu of it select Keymap. Now
you see a list. Click on Main menu -> Code -> Comment with
Line Comment (doubleclick) -> add keyboard shortcut.
A small window pops up. You can now simply press the shortcut you
prefer and click ok.
Don't forget to save your changes by clicking OK or Apply.
The configured shortcut should work immediately.
Copying over a solution I found in one of the comments in Jetbrain's bug tracker (see https://youtrack.jetbrains.com/issue/JBR-216#focus=Comments-27-4838035.0-0 )
[...]
I found the plugin "Keyboard Nationalizer". Install the Plugin, restart IntelliJ and execute the Action "Generate National Keymap" - that's it.
After generating a German layout, the shortcuts can be used again
If you are on macOS (MacBook, ...) and have a German keyboard you can make the command + / keymap work like this:
Step 1 - macOS settings
Disable the "Hilfemenü anzeigen" ("Open the Help menu") shortcut in the keyboard settings of macOS:
Step 2 - IDEA settings
In the keymap preferences of IntelliJ IDEA (or Android Studio) add the keymap shift + command + 7 for "Comment with Line Comment". Note: I used the "macOS" keymap settings as the basis, and adding a keymap will create your personal copy of the settings.
Now it should work the same way as in Visual Studio Code for example.
In my current version of IDEA v.20221.1.4 there is an option "Use national layouts for shortcuts (require restart)". Activate it, nothing changed.
Then I check the documents of IDEA, it says you need to install the "Keymap Nationalized" plugin to use it. Deatails about this plugin can be found here: https://plugins.jetbrains.com/plugin/14625-keymap-nationalizer
After install this plugin in IDEA. Double click "Shift" button in IDEA, the "search every" windows will be opened. Find the setting for Keymap Nationalized plugin. Now you can choose the language for the keymap. You will see new keymaps were added, for example there is a new keymap for the Comment with line added.
For MacBook Pro & Air, command + shift + 7 works fine in Visual Studio Code.
If you have a numpad, try using command + /(from the numpad). It worked for me.

Use VI keys everywhere instead of cursor keys

I like VIM a lot because it kind of doubles the power of my keyboard in a way. It's either in insert or motion or whatever they call it mode.
Navigating through source code, typing code, while being able to keep my hands in the touch type position is great.
But when a dialog box is opened (eg. the one using ctrl+F12), if I have to select something other than the first one in the list, I am forced to have to move my right hand to the cursor keys.
Is there a way so that I can use J and K or else something with ctrl or alt or something, so that I can select an item while keeping my hands in the touch typing position?
You can redefine shortcuts for the Up, Down, Left, Right actions in File | Settings | Keymap (the regular keymap that has nothing to do with IdeaVim). IdeaVim provides Vim emulation only for code editors like file editors, interactive language consoles, etc.
Edit: I guess you can't use j and k since characters typed in the structure window are reserved for searching. But you can use Ctrl+N and Ctrl+P which is the same as the navigation shortcuts for pop-up windows in Vim.
Edit 2: You can't use Ctrl+N and Ctrl+P as well due to this bug in IntelliJ.

How to disable escaping when copy and pasting in IntelliJ?

When I copy and paste string text into quotes Intellj always escapes certain characters like ", etc,. How can I disable this annoying feature?
You can use Ctrl+Alt+Shift+V (presumably ⌘+Alt / Option+Shift+V for OS X) to do Paste Simple (also available from the right-click context menu). This will paste your most recent clipboard content without escaping it.
Many other programs that offer "simple pasting" will use Ctrl+Shift+V instead, but in IntelliJ that opens an IntelliJ clipboard memory dialog, where you can choose previously copied text to paste.
Note that these are all default, but customizable, keyboard shortcuts.
I found the Ctrl + Shift + Alt + V combination a bit cumbersome, and after some digging I found an alternative solution that was more to my liking. I want to share it here in case it is useful to anyone else.
You can actually edit the key mappings for the paste simple command, and replace them with the standard Ctrl + V that most people are familiar with.
Simply go into File -> Settings -> Keymap and enter "paste" into the search box to bring up all the various paste commands. Double click "Paste Simple" and enter Ctrl + V for the shortcut.
You will be warned that the shortcut is currently assigned and you will be given the option to remove it. After doing so, you have pretty much replaced the annoying "enhanced paste" with the standard "simple paste".
Hope that helps someone out there :)
as of December 2019, at least in IntelliJ Ultimate 2019.3, there is a configuration option to disable this annoying behavior: Go to Editor --> Smart Keys --> Javascript and uncheck the "Escape text on paste in string literals" checkbox.

TextMate map key for next complete to command + spacebar

I found a lot of tutorials and forum questions around remapping key bindings in Textmate and for the most part I know what needs to be done as far as copy the KeyBindings file and then make the changes needed. More on what I am talking about here http://blog.macromates.com/2005/key-bindings-for-switchers/
I am interested in re-mapping the esc key for nextComplete to control + spacebar. The problem is I am having a hard time finding what the code is for the spacebar or if this is even supported.
I mainly do actionscript development in eclipes and code hinting dialogue is triggered by this key combo and I would like to have the same in Textmate. Hitting the esc key kind of sux. I thought I would get used to it but the fact is that it just kills the flow of typing the rest of your code.
I could use some help figuring out what he code is for the space bar. I know control key is the ^ symbol. I tested this by changing the keybinding to ^s and it remapped just fine.
I think this one can be done with the OS X gui:
System Preferences, Keyboard, Click Keyboard Shortcuts Tab
Click the little Plus, and choose Application: Textmate.app, Menu Title: Next Completion, Type Command Space (or Control Space) and click Add and that should work. You might want to remove conflicting shortcuts - possibly spotlight?
For future reference, I used Key Codes to find the key for space is: \UF20

Keyboard shortcut to Un/Comment out code in Mathematica 7?

A keyboard shortcut to comment/uncomment out a piece of code is common in other programming IDE's for languages like Java, .Net. I find it a very useful technique when experimenting through trial and error to temporarily comment out and uncomment lines, words and parts of the code to find out what is and isn't working.
I cannot find any such keyboard shortcut on the Mathematica front end in version 7. I know that it is possible to comment out code by selecting the code, right mouse click and select Un/Comment from the menu that appears but this is too slow while coding.
I tried to access this using the menu key Menu on the keyboard but Mathematica frontend doesn't respond to or recognise this key unlike other applications, this could have allowed a key combination for commenting. Can someone else verify that this isn't unique to my machine and that the key isn't recognised by mathematica. I looked at this question and looked in the KeyEventTranslations.tr file but I don't think there is any way to create a shortcut to do this(?). Should I just live with it?
Any other suggestions?
(I have seen there is an Emacs version of mathematica, I have never tried Emacs or this Mma version and imagine that it would have this ability but would prefer not to go to the trouble and uncertainty of installing it. Also I would guess that the Wolfram Workbench could do this, but that may not be worth the investment just for this.)
You can install the shortcut in Mathematica 7.0.x if you are willing to edit the Mathematica system file MenuSetup.tr. You can find it in the same location as the KeyEventTranslations.tr file (i.e. in the installation under "SystemFiles/FrontEnd/TextResources/platform"). In MenuSetup.tr, locate the following line under the definition of the Edit menu:
MenuItem["Check &Balance", "Balance", MenuKey["B", Modifiers->{"Control", "Shift"}]],
Immediately below that line, insert the following:
MenuItem["Un/C&omment Selection", KernelExecute[FE`toggleComment[]], MenuKey["/", Modifiers->{"Command"}], MenuEvaluator -> Automatic, Method -> "Queued"],
The Un/Comment Selection command is now available under the Edit menu, with the keyboard shortcut Cmd-/ or Alt-/ depending on your platform -- just like in Mathematica 8 where this command comes pre-installed.
Please take as read the usual disclaimers about hacking the Mathematica installation files -- no warranty is offered :)
I do not know of any way to map this function to some shortcut involving the Menu key.
Shortcut Key, No Menu
The preceding steps mimic what Mathematica 8 does by installing a new menu item. If you prefer to leave the menus unchanged, then you can install the shortcut in KeyEventTranslations.tr instead. Add the following line:
Item[KeyEvent["/", Modifiers->{Command}], KernelExecute[ToExpression["FE`toggleComment[]"]], MenuEvaluator -> Automatic, Method -> "Queued"]
You'll need a comma on the end of that line if it is not the last item in the list.
Select the code and press one of the following:
Alt+/
Alt-E-O
Alt+E+O
Notes:
Tested only on Windows, using Mathematica 8.
On my non-US keyboard (ABNT Brazil), the shortcut Alt+/ doesn't work, instead I use Alt+E+O.
Here is code for your KeyEventTranslations.tr file that will comment out code. I am still working on the other half.
Item[KeyEvent["/", Modifiers -> {Command}],
FrontEndExecute[{
NotebookApply[FrontEnd`InputNotebook[],
"(*\[SelectionPlaceholder]*)"
]
}]
],
This binds it to Alt+/ as it is in Mathematica 8.