Change Android Studio keybind for Code > Split > Design - android-studio

I am using Android Studio 4.1.1 on Windows, and I would like to use the key combinations "Alt+Shift+Left" and "Alt+Shift+Right", but those are bound by default to switching the editor's view mode between "Code", "Split" and "Design", and I cannot see them in the keymap settings, i.e. I cannot find how to remove them. I can set the two keybinds in the keymap settings, but they will be ignored and the view mode will switch instead.
I've always used those keybinds for another purpose, and would rather avoid having to use a different keybind set on Android Studio than I have on Visual Studio Code.
For your curiosity, my regular usage:
To move the cursor within a word such as camelCaseWord
ctrl+right to go from current position to the end of word
alt+right to go from current position to the next word boundary, in this case next capital letter(e.g. from m to C)
alt+shift+right to select from current position to next word boundary

You can find these keybindings in Keymap > Other > Tabs :
Select Next Tab in multi-editor file > Alt+Shift+Right
Select Previous Tab in multi-editor file > Alt+Shift+Left

Related

Visual Studio Code - "Add Selection to find next match" losing selection when vim keymap enabled

I have a new installation of Visual Studio Code (default configuration, with vim keymap). I want to use the command "add selection to find next match". I think this is equivalent to how multicursors work in sublime text and vim (with an extension), or Atom (find and replace: select next).
When I try to run the command directly by using Ctrl D it does not work, taking me to the last line in the file. This might be some kind of conflict that might be easy to solve.
More interestingly, when I run the command from the command palette Ctrl Shift P.
The first time selects the word I am at (well done!)
The second time selects the next occurrence of that word, but loses the selection, moving the two cursors right after the two first occurrences of the word.
The third time and next times nothing happens, the selection was lost in the previous time.
How to get the awesome normal behaviour that other editors have?
PD: I have now confirmed that this behavior is not present without the vim keymap, may they be compatible somehow?
Ctl + D is a default Vim keybind that scrolls the window down in the buffer. This is expected behavior for the Vim extension, and you should disable the mapping if you wish to use it to run the VSCode command "Add Selection To Find Next Match".
To do this, open the extension's setting by clicking File > Preferences > Extensions. From there, choose the Vim extension and select the option to Configure Extension Settings. There will be an option called Handle Keys, where you can enter JSON data to send certain key combos back to VSCode (and there's another option to turn off all Ctl + Letter combos, called Use Ctrl Keys). You can find some examples of such data on the extension's Marketplace page. Below is the snippet of code that I added to my settings.json file to get Ctl + D back.
"vim.handleKeys": {
"<C-d>": false
}
From my testing, it looks like changing this setting also fixes the behavior when using the Command Palette. It might be a bug, but who cares when you are most likely just going to use Ctl + D anyway. :)

vim copy/yank without leaving visual mode

In normal text edit after I select and copy, the selection stays still, so I can copy again quickly. But in vim when I press y in visual mode, I enter normal mode, so I need to select again. I want a quicker way.
Reasons:
When testing a console app, I copy test data from text editor and paste into console. Then I find bugs and edit code, the clipboard may change and I need to copy and paste test data to test again
You can reselect last visual region typing gv
*gv* *v_gv* *reselect-Visual*
gv Start Visual mode with the same area as the previous
area and the same mode.
In Visual mode the current and the previous Visual
area are exchanged.
After using "p" or "P" in Visual mode the text that
was put will be selected.
You do not need to be in visual mode in order to yank text. While in normal mode, the yank command can be combined with a motion: y{motion}. You can read more about that here: http://vim.wikia.com/wiki/VimTip312#Copying_and_cutting_in_normal_mode
It also sounds like you would like to yank text into the system clipboard. On most Linux distributions, you can do this by yanking text into the + register. Depending on the distro, you may need to install gvim.

How to turn off auto-indenting in Java in Android Studio (2.1.1)? (Windows 7)

If I have a line with 8 spaces (yes, spaces, not tabs) and some text...
x=3;
... and my cursor is placed after the semicolon, when I hit Enter it positions the cursor under the x. In other words it indents it 8 positions. If I then hit backspace it positions the cursor after the semicolon! I expect the backspace to take me back 1 space on the new line.
In Editor>Code Style > Java, Tab size = 1, Indent = 0, Continuation indent = 0. N.B. that if I try to set Tab size to 0 it's 1 next time I bring up that dialog, so 0 is apparently not acceptable to Android Studio, even though I see it suggested in several S.O. questions.
In Editor > Code Style I UNchecked Detect and use existing file indents for editing and now if I hit Enter with the cursor after the semicolon it positions the cursor 4 spaces in the from the right, in other words it still indents, just not as much.
N.B, that after making these settings I did a File > Invalidate Caches / Restart.
I don't want any automatic indenting. When I hit Enter I want it to position the cursor at the first position of the new line, and when I hit backspace I want it to go back 1 position, just like an ordinary "dumb" editor. How do I turn off all automatic indenting in Android Studio?
Android studio tries its best, like most IDEs, to help you organize your work and make it successful. It is normal, but of course, there is a way to disable it.
Note: Your project can be really messy when disabling this, if you want to properly indent a block of code, highlight it then press CTRL+ALT+L, this will indent the highlighted for you.
So, to disable it, press CTRL+ALT+S, this will open settings. Now, go to the Editor tab at your left, where you then go to General, then Smart Keys. You should see a "Backspace" part. Over there, there will be a dropdown menu, click that then select the "Disabled" option. (Settings>Editor>General>Smart Keys> )
Is this just the normal, expected behavior of A.S.?
I'd say it's the normal expected behavior of any IDE to indent correctly while you are typing. Your next line is supposed to start at the same position than the previous and if you close a bracket A.S. will automatically unindent it once.
Now on your topic :
To make your backspace key just delete the space you can go to : Settings -> Editor -> General -> Smart Keys -> Backspace -> Unindent and put 'Disabled' instead of 'To proper indent position'

Vim: How to shrink the visual area

Let's say that I've got the following text:
This allows you to select some text using Vim's visual mode
With the cursor on the 'a' in 'allows'. If I type vaw I switch to visual mode and then select "a word" ("allows "). If I repeat the aw then Vim also selects the "you ". Let's say I do this once more (highlighting "to ") and then realize that I've gone too far.
Is there a way to shrink/reduce the size of the visual area (other than using the h,j,k,l keys)?
I'd love to be able to either 'undo' my last command (i.e., have Vim move the selection back to before I typed that last 'aw') or else use the motion/text object commands to reduce the size of the visual area.
yes, you can keep pressing ge till it selecting allows again.
Based on your post (and on this one), I decided to make the vim-visual-history plugin that keeps
a traversable record of previous visual selections with [v, ]v, [V and ]V. So
in your case, you would just do [v to go back one selection. You can keep on pressing [v to go back further in time, and use ]v to go forwards again. The plugin works for your case, and also selections using text objects etc.
[count][v : Reselect previous visual selection
[count]]v : Reselect next visual selection
[V : Reselect first visual selection
]V : Reselect last visual selection
You can also give a count to jump through the history faster:

Resharper move line up down not working

I can't make it working, move line up or down doesn't work. When I reset keyboard for VS and applay scheme for Resharper it ask me for this :
and if I take first selection , then alt + up switch me between methods, if I use second selection then this combination does not effects.
Alt+Up is not a ReSharper shortcut to move a line. It most likely belongs to the Productivity Power Tools extension, that has a feature to move one or more (selected) lines.
Personally, I don't like this feature in PPT, since it will just move the line(s), regardless of their scope, causing compilation errors. I much rather use ReSharper's feature of moving blocks of code up or down, by pressing Ctrl + Shift + Alt + ↑/↓ or ←/→ - when on the beginning of the line, it will move the entire line or block of code, but can also be used to move entire methods, change the order of parameters, etc.
I ended up resetting my Resharper shortcuts. Then when prompted with the dialog, chose Use Visual Studio Commands for the Alt+Up & Alt+Down shortcut.
You could also set this manually in Tools > Options > Environment > Keyboard. Search for "MoveSelectedLines" and then assign Alt+Up/Down to the appropriate command.
On my machine with Resharper 2016.1 it makes a difference on what position the cursor is located:
cursor located from 1st to last character on the line: the shortcuts work as described by Igal Tabachnik
cursor located on white spaces before 1st characters of the line the shortcuts are ignored.
Regards
Bernhard

Resources