XCode9 how to get right click > Structure > Reindent back? - code-formatting

I see that XCode9 is messing up the indentation of my code. Before this could be fixed with right click > structure > re-indent. How do I get equivalent behavior in XCode9?

This won't get the Structure->Re-Indent context menu back but might be useful.
There's a ^I (ctrl + i) shortcut for that, which re-indents selection.
If you don't want to use Key Bindings, the command is available using the menu:
Editor->Structure->Re-Indent
Note that default combination looks very much alike ^| (ctrl + shift + \) on Key Binding pane . I've been banging this combo for some time and even redefined the shortcut to ctrl+shift+\ before figuring out the correct one:

Related

IntelliJ IDEA: Can't type { and [

So I have a problem where in IntelliJ IDEA I can't type In
<br>{ --(Alt Gr + B or Ctrl + Alt + B)
and
[ --(Alt Gr + F or Ctrl + Alt + F)
<br>
I did try to edit shortcuts but there are no shortcuts that match mentiond ones
And when I try using SquareBrackets I get a message a little bit like this: "Cannot perform refactoring. Caret should be positioned at the name of local variable or expression to be refactored"
How can I fix this problem?
It worked for me by going to Ctrl+Shift+A (actions) -> Registry... and then disabling "actionSystem.force.alt.gr"
Worked for me:
While focus is on PyCharm then Ctrl+Shift+A (actions) -> Registry... and then enabling "actionSystem.force.alt.gr"
An other solution (not related to Jetbrain's suite).
This solution suits you if :
The problem is sporadic (occurring at irregular intervals and eventually disappear)
AltGr combinations seems not works on some other windows app
In this case this is a well known bug in Windows, just close all your RDP sessions and the AltGr will start acts as it should.
Guys I found a solution to BOTH of the problems So here are the solutions:
This applies for:
KeyBoards Without [ and { keys (I just English-UK ones have those keys)
and IntelliJ IDEA Deafult KeyMap (May work for some others)
For the "Can't type [ in IntelliJ IDEA":
1.Press Ctrl + Alt + S ,Alt Gr + S or Goto: File > Settings > KeyMap
2.Extend Folder:Main Menu, then folder Refactor and THEN folder Extract
3.Right-Click onto Field...
4.In the pop-up menu Click on Remove Ctrl + Alt + F
For the "Can't type { in IntelliJ IDEA":
1.Press Ctrl + Alt + S ,Alt Gr + S or Goto: File > Settings > KeyMap
2.Extend Folder:Main Menu, then folder Navigate and THEN folder Bookmarks
3.Right-Click onto Implementation(s)
4.In the pop-up menu Click on Remove Ctrl + Alt + B
Hope that helped You :D
There are related issues on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-177327, https://youtrack.jetbrains.com/issue/IDEA-91975
Problem should be fixed in IDEA 2018.3.
By the way, you could try to add "actionSystem.force.alt.gr=true" option using "Help | Edit Custom Properties"
win10
Pycharm 2018.1.3
ctrl+shift+A
Registry
ENABLE "actionSystem.force.alt.gr", which was disabled initially
SOLVED for me!
In my case it was caused by LaTeX plugin for IntelliJ IDEA. After its installation the 'Toggle Star' option key was set 'alt+shift+8' which coincides with { of my keyboard. Hence the solution is analogous to your own answer:
1) Open Keymap (double-shift and type keymap)
2) Expand: Main menu > LaTex
3) Right-click 'Toggle Star' and remove the mapping.
4) Apply + Ok
If your problem is happening all over Windows and you have two different active Keyboard Layouts, for example English and German, this is what worked for me (don't ask me why):
switch to english (win + space), and type a { there (shift + Key to the right of P).
now switch back to your original language and it should be working again
I had the same problem but with PyCharm.
Unfortunately none of the mentioned answers worked for me. I am on an MacBook using a German layout keyboard. The Problem for me was a changed default setting in the terminal settings. I had to disable "Use Option as Meta Key". On a German Keyboard many "special" characters like [],#, {}, etc. are alt(option) Key-Combinations. I think this is true for other european keyboards as well. (I know for the suisse and the danisch for sure)
In my case, another application was using Alt Gr + 7 && Alt Gr + 8 shortcuts for other processes. So if previous solutions are not helpful, make sure that shortcut is not being used by another program.

How to return cursor to method name after Ctrl + LEFT MOUSE on this method? [duplicate]

I know Ctrl+Shift+Backspace is used to go to the location of the last edit.
But I want to jump to whichever location I was most recently at, not necessarily one where I edited anything.
For example, if I jumped to a declaration using Ctrl+B, then I want to go back to where I was before jumping.
Alt + Shift + ← (Left Arrow)
or
Ctrl + E (Recent Files pop-up).
Also check:
Ctrl + Shift + E (the Recently Edited Files pop-up).
Mac users, replace Ctrl with ⌘ (command) and Alt with ⌥ (option).
Update In v12.0 it's Alt + Shift +← (Left Arrow) instead of Alt + Ctrl + ← (Left Arrow).
Update 2 In v14.1 (and possibly earlier) it's Ctrl + [
Update 3 In IntelliJ IDEA 2016.3 it's Ctrl + Alt + ← (Left Arrow)
Update 4 In IntelliJ IDEA 2018.3 it's Alt + Shift + ← (Left Arrow)
Update 5 In IntelliJ IDEA 2019.3 it's Ctrl + Alt + ← (Left Arrow)
The underlying problem is Ctrl+Alt+Left and Right are used by window managers to switch workspace and/or OEM utilities to change the screen orientation.
You can change the assignments using
File / Settings / Keymap then Main Menu / Navigate find Back and Forward and right click to Add Keyboard Shortcut to set an alternative key chord.
Alt Graph+Left and Alt Graph+Right works well for me (IDEA 13.1.4 on Ubuntu under IceWM).
CMD + [ -> Go Previous
CMD + ] -> Go Next
==========
For OSX, cmd + [ and ] are the best choices to go back & forth, Since they are found so near to fingers, avoiding you wrist twisting a bit, one keypress lesser, ideal for users in vim mode.
As the OP requested, this works well with cmd + B which facilitates jumping inside/to the method/variable definition and comes back immediately using cmd + [. Give a try.
For Ubuntu, Ctrl + Alt + Left and Ctrl + Alt + Right work fine.
By default these keys are assigned for Ubuntu's workspace navigation.
You need to disable that by going to :
System Settings > Keyboard > Shortcuts Tab > Navigation and disable Switch to workspace left and Switch to workspace right by pressing Backspace.
Or you can choose to change shortcuts in Intellij itself:
File > Settings > Keymap > Main menu > Navigate > Back/Forward
Q & A is built into Intellij ...
CTRL/CMD + SHIFT + A x 2 TYPE caret
For version 14. On mac, it is ⌥(alt) + ⌘ + ←
Mostly the default shortcut key combination is Ctrl + Alt + Left/Right. (I'm using the linux version)
Or you can have a toolbar option for it. Enable the tool bar by View -> Toolbar. The Left and Right Arrows will do the same. If you hover over it then you can see the shortcut key combination also.
Just in case the key combination is not working (this can be due to several reasons like you are using a virtual machine, etc) you can change this default key combination, or you can add an extra combination (ex: For Back/Move to previous Ctrl + Alt + < or Comma).
Go to Settings -> select keymap (type keymap in the search bar) -> **Editor Actions -> search for back and find Navigate options -> change the settings as you prefer.
OSX and Android Studio version:
CMD+ [ and CMD+ ]
to move to the previous carret location.
Many excellent answers so far, and they do answer the question...But, if you don't want to have to deal with disabling graphics driver's settings, or creating new keyboard mappings, or are developing through a remote session (RDP) or within a VM that intercepts your keystrokes, good-old keyboard navigation still works. Just do Alt-N to bring up the Navigate menu and then hit the B key.
Please note that you don't hit all keys at the same time. So:
Alt-N wait B
This is what I use all the time, for exactly the case that the OP asked about.
Also, this will probably hold through any IntelliJ updates.
In IntellJ 2017.2,
Ctrl+[ and Ctrl+] navigate between previous locations in the current file.
Ctrl+Alt+← and Ctrl+Alt+→ navigate between previous locations in all files.
Depends on the Keymap selected.
Keymap: Mac OS X ⌘ + Left Right Arrow Keys
Keymap: Mac OS X 10.5+ ⌘ + [ / ]
I was facing similar problems in Pycharm. To resolve change your Keymap in Preferences.
Navigate back/forward
Ctrl + Alt + Left/Right
Using the following ways using only two keys will be the easier:
control + Tab
or
Alt + Left/Right
For Mac users Use Command+[ for backward and Command+] for forward.
You can use the below to navigate back in 2017.3.4
Alt + Left
Like #itsneo said, I personally find ⌘ + [ and ] the most convenient ones on a mac. But I can understand if you come from Linux side of things. Then you can use ⌘ + alt + ← or →.
With version 2018.1 the keyboard short cuts for navigation are Shift+Alt+Left or Right
Press Ctrl + Alt + S then choose Keymap and finally find the keyboard shortcut by type back word in search bar at the top right corner.
Intellij 2021.3.2 Basic Shortcuts
Ctrl+Shift+E = Recent Locations
Ctrl+E = Recent Files
Ctrl+N = Find the Class
Ctrl+Alt+B = Navigate the Class
Ctrl+Shift+T = Open the Test Class of the Class
If you are on a mac keyboard using with UNIX OS;
control + alt + command + left or right should work for sure.

How to fold try/catch, switch, for, while and if statements in IntelliJ Idea?

IntelliJ Idea fold if and other statements in JavaScript, but not in Java. How can I get this feature? Maybe you know some plugin or settings?
I don't think that it's possible from Code > Folding or using the icons from the left bar (collapse/expand), but you can do it in a harder way: manually.
E.g.:
select the try block
Code > Folding > Fold Selection / Remove Section ( Ctrl + Period, where Period is the .)
you'll see ... instead of that block
now that block also has the icons for collapse/expand on the left bar
In Android Studio, in order to fold a try/catch structure -
In the editor window, select the left brace after try
Type on keyboard CTRL + Shift + .
Now the complete try { .. } block will be folded.
If I want to reduce a try / catch section, it doesn't work for me on Intellij CI 2016, under Ubuntu 16.04 OS.
Even with shortcut or using menus.
Using menus Code > Folding > Fold Selection / Remove Section ( Ctrl + Period, where Period is the .), it'll close the entire function where the try/catch block is.
It doesn't work either if I use shortcut Ctrl+ Shift + .
Seems to be a conflict with other shortcut existing on the OS I'm running onto.

Keyboard shortcut for going onelevel up in midnight commander [mc]

Is there a keyboard shortcut for going one level up in the directory tree in midnight commander (mc), which will save me from going all the up to the ..?
As shown below - say I'm in a directory that contains tonnes of stuff, and its painful to scroll all the way up. Its clickable, but nothing beats keyboard shortcuts!
If you go to Options->Panel-Options and tick the "Lynx-like motion" option you can use left-arrow to go to the parent directory and right-arrow to enter a directory.
Does Home, Enter count as a keyboard shortcut?
Short answer: No.
Longer answer: Ctrl + PageUp goes to the last diretory - not the parent, but this may be what you want in most cases.
(https://www.midnight-commander.org/ticket/2420)
Without changing the default setup Alt + Y and Alt + U go to previous and next directory in history, which may be enough on most cases (Alt + H to see the full history). If not, you always have Home, Enter.
Alt + Arrows are used to move between windows on byobu/tmux.
To add a custom shortcut (like Backspace) to your user config:
echo 'CdParentSmart = backspace' >> ~/.config/mc/mc.keymap # Globally in /etc/mc/mc.keymap
Here more related handy shortcuts.
In /etc/mc/mc.default.keymap find and uncomment CdParentSmart in [Panel] section. If it's not there, add it. And set a key you want. Behavoir similar to Total/Double Commander would be CdParentSmart = backspace. So it will backspace command line, if it's not empty. Or will level up from any place, if command line is empty.
The file should be edited when MC is not running, as it is resetting it to currently loaded settings on exit.

Is there any shortcut key to align code content in Xcode?

Is there any shortcut key to align code in Xcode? Just like Ctrl+K+D in Visual Studio?
⌃ + i (ctrl + i) is the shortcut key equivalent to Editor > Structure > Re-Indent ( in Xcode 6.4)
This will re-indent the line the cursor is on if no text is selected, or it will re-indent your selection.
1.) Select the text you want to align,
then
2.) press ctrl(^) + I.
If you want more than just indentation Xcode does not yet offer built in code formatting but you can use external tools like Uncrustify to apply a consistent code style.
I described how I last set this up here: http://blog.carbonfive.com/2009/08/07/code-formatting-in-xcode/
Turn on automatic code indentation, then Command+X, Command+V. In other words, cut and paste in place. If your syntax is correct Xcode shouldn't have trouble formatting it (unless you're missing newlines).
There's a menu command:
Edit > Format > Re-Indent
I don't think there's a shortcut on it by default, but you can easily create one in the Key Bindings tab in the Xcode Preferences.
Use default, "COMMAND [" and "COMMAND ]"
Simple!
as #McGordon says, Control + i works on indenting.
(As of Xcode 4.1) its there in the menu at
Editor --> Structure --> Re-Indent
Select the text you want to Align And then press Control(ctrl)+I.
The defaults way Xcode is set up is to use Control + i (also known as ⌃ + i)
If you want to change this then:
Open xcode preferences
Go to Keybindings
Search for "Indent"
Edit and change it to whatever you like.
=> Select All Code by (command + A)
=> Press (control + ]) for indent.