How to add a keyboard shortcut to the Team->Add command in eclipse - eclipse

I would like to have keyboard shortcuts to Team->Add and Team->Commit in eclipse. I am using eGit.
I added them in Preferences->General->Keys and that works in that the keys show up on the menus next to Team->add and Team->commit.
However, when I press the keys nothing seems to happen. The little Key Assist window pops up after the first key and shows me the matching commands, with 'Add to Git index' included, but the file is not added to the git index.
More generally, I would like to be able to commit the current project to git without having to use the mouse.

Make sure that the Git command groups are available. Right-click a blank area of menu bar -> Customize perspective -> Command groups availability; make sure the 'Git' entry in the available command groups is selected.

When you add a keyboard shortcut in eclipse, you also have a scope attached to it (the "When" field, in Eclipse terms). Make sure that it's set to a scope that'll be in use when you fire the shortcut, like "Java editors" or the more broad "In Windows". (NB: I've not had a chance to test this myself, so I could be barking up the wrong tree).

Related

What is the equivalent shortcut for CTRL+D ("add selection to next find match") of VSCode in CLion?

Usually in Visual Studio Code, if I want to delete or modify a certain word from my file, I can highlight one of the words and then continuously press CTRL+D to highlight the rest of that same word in the file. But, in CLion, I am unable to find the equivalent shortcut.
I've Googled and searched here on StackOverflow but no luck. Maybe this shortcut doesn't exist in CLion? Can anyone confirm?
EDIT: It's also known as "Select next occurence" in other JetBrains products.
EDIT: The answer is ALT+J
it is alt+j in all of jetbrains products
So I just want to hit on a couple of options that you have, because I work with both CLion & VSCode as well, and needed the same exact keybinding in CLion.
KEYBINDING FUNCTIONALITY SEMANTICS
Unfortunately, it appears that no one cares about standardizing semantics when it comes to editor functionality/features, and keybindings. It can make moving from one editor to the next difficult, and flat out something many people just would rather not have to do.
Please Note:
_I am no expert on JetBrains IDE's, I am somewhat of an expert with VSCode though. I say this because, IDK how much JetBrains IDE's vary from one to the next, however, from having CLion, IntelliJ, and Access to Ryder I can tell you that in the standard IDE's the keymappings seem near Identical, but in Ryder, the keybindings are totally different.
DEV ENVIRONMENT
BOUND-KEYS (dev env's default)
SEMANTICS
CLion
ALT+J
"Add Selection for Next Occurrence"
Visual Studio Code
CTRL+D
"editor.action.addSelectionToNextFindMatch"
Visual Studio 2022 (IDE)
SHIFT+ALT+.
"Edit.insertNextMatchingCaret"
the The correct semantics for referring to the functionality you seek in CLion is contingent on the environment that its being implemented in. The following demonstrates how to correctly reference it in both JetBrains & Visual Studio Environments:
Add Selection To Next Find Match Ctrl+D editor.action.addSelectionToNextFindMatch
Once you know the semantics of the functionality that you want to customize, you no longer have to resort to using any editors default key mapping. You asked about, CLion, so I will demonstrate, in an image (or screenshot) below, how you can change the keybinding to be anything you want it to be.
To get to the window you see in the photo navigate by following the steps below.
Starting from the text editor, find the word 'FILE' on the 'MENUBAR' located at the very top of your screen.
Click on 'FILE' to drop open the 'FILE MENU'.
Scan through the __FILE MENU'_s ITEMS, until you see the selectable ITEM named 'SETTINGS' (it will have a wrench icon next to it).
4 Select 'SETTINGS' by left-clicking it, and you'll open the 'SETTINGS MENU' open.
Another 'LIST' will appear on the left side. There will be 'BOLD ITEMS' and regular weighted SUB ITEMS. Find the 'BOLD ITEM' that reads 'KEYMAP'.
Select 'KEYMAP'.
The image above shows the view in my IDE of the keymap menu. You can see a red arrow, as well as a green arrow, in the image.
GREEN ARROW
The green arrow shows where you can change the entire Keymap, as you can see in the image, mine is set to VSCode, and as far as I can tell, every keybinding is the same as in VSCode. You do have to download the VSCode keymap plugin though.
RED ARROW
The red arrow shows where the "Bound Keys" are listed. Right click on the keybinding and you'll see a menu that reads
Add Mouse Shortcut
Add Keyboard Shortcut
Add Abbreviation
"it may also have options for removing keybindings and mouse shortcuts, it all depends on how the keybinding you click on is configured"
To set the keybinding select Add Keyboard shortcut, and set it to what ever you want.

See unsaved changes in vscode

Sometimes when closing vscode, or a tab therein, I get a dialogue asking "Do you want to save the changes you made to filename?" However, the unsaved edits are actually from a previous session that was closed without such a query, probably when turning off the computer, so I can't remember if it was meaningful edits, or maybe just an accidental key-press, like a shortcut gone wrong; and doing undo to revisit the last edits doesn't work either.
My question: How can I see the diff between the saved version of a file, and the version in the editor window? I think it would be nicest just to have a "show diff" option in the dialogue, but for now I'm also happy with a command line diff command.
I'm using ubuntu 20.04.
I'm using VSCode version 1.52.1 on MacOS and I had a similar problem that may not be the same problem, but I'm guessing it will work for you as well.
When you're in the Explorer view, in the upper left part of Explorer you have your "Open Editors." If that shows a dot to the left indicating that the buffer has changes in it, you can right click the file name and select "Compare with Saved." This will open another buffer to the side that will show you any unsaved changes.
To get rid of that window (it took me a bit to figure this out I'm sorry to say!), you can click the 'X' to the left of the extra buffer in "Open Editors."
Hope this works for you!
A few bright notes for the keyboard players out there:
The command you are asking about has a default shortcut. Unless you've applied a keyboard map extension, the Ctrl+Kd arpeggio opens the very same diff view between the active and saved versions of the current file. The default shortcut to close an editor tab (be it the diff or a file or anything at all) is Ctrl+W.
The command, like any command in VSCode, is also accessible via the Ctrl+Shift+P command dropdown (on Linux, F1 opens it too). Start typing e.g. compa sav (it saves your keyboard wear and tear to shorten words to a prefix which is unambiguous enough), and the list will shrink dynamically to just a few commands. Yours is File: Compare Active File with Saved. When it's close to the top enough, navigate the list of commands with the down arrow and execute it with Enter. As a bonus, you may click on the little gear to the right of the command currently highlighted in the list and redefine its shortcut, if you use it very often and prefer a chord shortcut to the default arpeggio one. Sorry, there does not seem to be a shortcut in lieu of the gear click. If there is, please let me know!
But if you really, really want to right-click on the filename in the Open Editors view of the Explorer sidebar, you can open that view directly with, you guessed it, a shortcut: Ctrl+Ke. And if you change your mind on a dime right at this moment, or realize that you in fact never had a mouse to do the right-click in the first place, use Shift+F10 to drop down the "right-click menu", properly called the context menu, which you navigate with arrows and execute with Enter (that's kinda a common theme, as you probably noticed). This works mostly anywhere the right-click does.
While in the Open Editors view, to switch to an editor file tab, move the selection to the desired file. Press Space to bring the file into view but stay in the Open Editors view, or Enter to bring the file into view and shift the keyboard focus to it. Pressing Ctrl+Shift+E brings focus back to the editor from any view in the Explorer sidebar. The same shortcut moves focus to the Explorer sidebar from the editor.
Happy ♬ k'boarding ♬!
ctrl+shift+P (or command+shift+P on mac) and fuzzy search for "compare changes with saved files"

How to disable eclipse4 built-in keyboard shortcut?

Eclipse 4.2 seem has some built-in shortcuts, such as Ctrl+P, Alt+C, Alt+X etc, you can not find them from "Window->preferences->General->Keys". I'd like to re-define these shortcuts, e.g. bind Alt+X to run maven build, but when i press Alt+X, at the bottom right corner of Eclipse, it flashes quickly and my mouse is out of control, i think this is because of shortcut conflict.
Anyone who know how to disable the built-in shortcuts? Thanks.
Edit:
Ctrl+p is only bind to one action.
When i click Ctrl+p, the bottom right corner show, this message is from from eclipse:
Well, the above is the good situation--at least you can choose which action to run. for Alt+P, Alt+c you have no chance to choose, eclipse is flipping and you are out of control.
Are you certain there isn't something in your OS or another application that is handling those keyboard triggers? If you assign a keyboard shortcut in Eclipse's Preferences, it will indicate when there is a conflict; if you don't see that, then it's not an Eclipse shortcut.
I found the root cause of this problem, i import all my keys from Eclipse 3.7 to 4.2, most of them works, however some of them conflict but Eclipse fails to show the conflict shortcuts, Let's say, Ctrl+P, this is print shortcut for eclipse by default, in eclipse 3.7 i bind Ctrl+p to another command, after import, eclipse 4.2 shows just like 3.7(see above), however in fact it still has conflict even though it does not show the conflict. I think this might be an eclipse bug. I'm the one who use shortcut extensively. Hope this help others with migrating shortcuts.

Eclipse Shortcut for Team - Synchronize with Repository

What are the shortcuts for the context menu actions "Team -> Synchronize with Repository" and "Team -> Update" on the whole project?
I have already found shortcuts, but these are executed only on the file i have currently opened. But I want to execute it on the whole project without having to scroll the project explorer to the top and right-clicking on the project.
If there are no such shortcuts, how can I create them?
As john.k.doe indicates, that's the right solution, but you also need to do something else in order to make the shortcut actually work, which is go to Window > Customize Perspective > Command Groups Availability and there just check the SVN box ;)
you can almost always get the key shortcuts you want by
go to preferences type "keys" or go to General -> Keys
in the field presented when you click on "Keys"
in the left pane, type the command you are interested in setting up a shortcut for:
the image below is from my mac, but it works the same way on windows/linux, you just might choose something besides Cmd-Y as your shortcut modifier. the U under User indicates that i was the one to add that modification.
I have written a small Eclipse plug-in which selects the active project in the Package Explorer so you can execute other actions (like 'Sync with repo' and 'Update') on it. I think this approach is more flexible compared to writing a plug-in that selects the project and executes a predefined action.
You can get the plug-in at http://code.google.com/a/eclipselabs.org/p/eclipse-tweaks/downloads/list, it is named "com.xakcop.select". Download it and put it in the dropins/ folder of your Eclipse installation. Then when you restart Eclipse, you will find a new command Select project in Windows->Preferences->Keys. The default key binding is Ctrl+Shift+Backspace but you can change it to whatever you want.
When you are in the Java editor just press Ctrl+Shift+Backspace, this will select the project that the current file belongs to in Package Explorer. Then press the shortcut for "Synchronize with repository" and you are done.
The source code of the plug-in is also available as part of my eclipse-tweaks project: http://code.google.com/a/eclipselabs.org/p/eclipse-tweaks/source/browse/com.xakcop.select
I think the answer to this question adresses the issue.
The quickest way I've found to update/synchronize, after having set the shortcut keys, is to click on the minimize button in the Project/Package Explorer and then press the keys. After the update, simply clicking on the last used file in the editor returns to the previous workspace state (provided the "Link with Editor" button in Project Explorer is selected).
I should clarify: I use a working set for each project. The working sets are displayed as default Top Level Elements in the Package Explorer so, by clicking on the minimize button the desired Project' working set, they collapse and are easy to select. Then, I apply the shortcut on the selected working set.
From my point of view, the problem is the focus of the commands you execute.
The Team commands Snychronize and Update are executed on the current object (In my case). As you noticed, when you execute the command on the project, the project is synchonized - when you do it on a file, only the file is synchronized.
What I did as workaround is the following:
I created Key-Bindings for the commands Show in (Navigator) (Alt-N), Go to (Alt-G), and Show View (Naviator) (CTRL+SHIFT+Q, N).
With Alt-N I show the current File in the Navigator. I can then use the keys to navigate to the root that I want to synchronize (it's not always the whole project for me). If the root is to far away I use Alt-G and type the Project or Folder where I want to go to and execute afterwards the Synchronize commands.
(Go to works only in the current view)
If you have selected the Project once you just have to switch to the navigator (Show View command) and execute your synchronize commands.
You could also use rgerganov's plugin then you would not have to execute as many commands.
The procedure works also with other views (package explorer, project explorer)
What about this approach? It should also work for other SCM's or commands you want to execute on any object in the explorer views.

Navigating menus in Eclipse without moving my hands

If you're as lazy as I am, you don't want to go moving your hand every time you need a menu in Eclipse. Is there any way to navigate menus in Eclipse without moving your hands to the mouse or the arrow keys?
I've searched for key bindings for menu navigation (replacing Up/Down/Left/Right), but came up empty.
UPDATE
To clarify, I am familiar with a lot of the features mentioned in the answers, such as "Show Key Assist", and "Quick Access". I've found that the only time I'm ever really moving my hands is to navigate through a list of items, such as the Package Explorer or the Open Resource dialog. I haven't found any alternatives to the arrow keys for these actions.
I like to bind "Show Key Assist", and "Quick Access" to convenient keys, in order to get a list of all menus/commands/views accessible from the context I am currently in.
This isn't really a replacement from ALT+arrows, but it can help reduce the menu exploration you need to do in order to find the right action to launch.
As #VonC mentioned, I'd use Quick Access (CTRL+3) for most commands that don't already have a keyboard shortcut.
You can also use mnemonics to access most menu items. i.e. ALT+F P for print, or ALT+R N for the Run Configurations dialog.
F10 will open the left most menu on most OSes. CTRL+F10 will open the view menu from within a view, and the ruler menu in a text editor. SHIFT+F10 will open a context menu in almost all locations.
PW
If you want to navigate between views of eclipse, you can use Ctrl+F7 & then up/down arrow keys to select the one. For 'Open Resource Dialog', you can use Ctrl+Shift+R.