Move Cursor Up/Down Lines - visual-studio-2012

I'm trying to mimic the functionality I set in Sublime Text that allows me to move the cursor much like 'j' or 'k' in VI. In the Windows world I guess it would be similar to a pgup/pgdn, however I'd like to just go up/down one line not one page.
Here's my bindings in Sublime Text that I'd like to mimic:
[
{"keys": ["ctrl+i"], "command": "move", "args": {"by": "lines", "forward": false}},
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": true}}
]
Edit: As Logarr pointed out, the easier way to phrase this is I want to mimic the Up/Down arrow keys using ctrl+i and ctrl+k

There are already Vim extensions for Visual Studio. There is the free VsVim extension that works in Visual Studio 2010+ and ViEmu which works in Visual Studio 2003+ plus a few other applications.
If you just want to remap the up and down keys, then you can change the keyboard mapping. From Tools->Options find the Keyboard section. From there you can change the key bindings for Edit.LineDown and Edit.LineUp. You may want to select the Text Editor for the "Use new shortcut in:" setting so these changes only affect the text editor.

This would have been trivial if Microsoft hadn't ripped the macro functionality out of Visual Studio.
You could install AutoHotKey and write a simple script. This would have the advantage that you could apply these keymappings to any applications you like as well as Visual Studio.

Related

User key bindings in Sublime Text 3 doesn't work

I'd like to customize some of the Sublime Text 3 keybindings to mimic IntelliJ IDEA. One of them is opening a file from the current project, also known as Goto Anything in Sublime jargaon. I followed the instructions in this answer to find out that the default key binding for "Goto Anything" is ⌘ + p on a Mac, like so:
{ "keys": ["super+p"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} }
I added a new keybinding as follows:
[
{ "keys": ["shift+shift"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} }
]
It, however, doesn't work; pressing shift twice in rapid succession does precisely nothing. When I open the console, I see the following message:
Unable to open /Users/me/Library/Application Support/Sublime Text
3/Packages/Default/Default (OSX).sublime-keymap
According to this ticket, this message is harmless but misleading, and is just an indication that Sublime is opening a file.
What's wrong then?
OP here; I found this post in Sublime blog.
ST doesn't support using only modifier keys in a keybinding.

Conflict with sublime hotkey

I am working with the sublime 3 text editor. I am modifying the User version of the keymap, however, it does not seem to be replacing the default keymap hotkeys. Specifically, in the Default keymap, I see the following assigned for the "copy" hotkey:
{ "keys": ["ctrl+insert"], "command": "copy" },
{ "keys": ["ctrl+c"], "command": "copy" },
There are two hotkeys assigned for the copy command, and I am not sure why. I use the latter command in my User keymap, but the hotkey is not working. The ctrl+insert hotkey is the one that is taking precedence.
Is there a way to modify the Default keymap for Sublime?
I don't see this conflict. But if you do, you can set a hotkey command to none if you don't want it to use.
{
"keys": ["ctrl+insert"],
"command": "none"
},

Use in Visual Studio Code (Vim extension) CAPS instead of ESC

I use Debian and I switched from Vim to Visual Studio Code, when I noticed, that there is a Vim movement extension for VS Code from vscodevim. While I was using Vim, I mapped my Caps lock key to the ESC key. In Vim it works perfectly, but VS Code is not reacting on a Caps lock input.
I hope there is a solution. If there are any questions feel free to ask.
This is how I changed my keyboard layout:
I navigated to /etc/default/
and edited the keyboard file. This is how it looks now
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="pc105"
XKBLAYOUT="de"
XKBVARIANT=""
XKBOPTIONS="caps:escape"
BACKSPACE="guess"
The Caps lock key works also in other programs e.x. "Synaptic Package Manager"
Late answer, but may be useful for someone:
Switched CAPS and ESC in Ubuntu over the keyboard preferences section. Worked in almost all applications, but not in Visual Studio Code.
So I modified VS Code settings:
{
"keyboard.dispatch": "keyCode"
}
and it worked.
For those who have the same problems on Linux:
If in your system wide config, Caps Lock is Esc, Esc is Caps Lock ( ['caps:swapescape'] ),
disable the key mapping in your system. Make it default.
In VSCode, press ctrl+shift+p and select Preferences: Open Keyboard Sortcuts
search for the vim_escape
double click on it and press original Caps Lock and save it.
Edit your keymap config in your system.
That is it.
There is no problem. Keys are working as expected.
Enlighten by an answer from this question.
In Visual Studio Code, how to toggle between vim-emulation and no-vim-emulation when the vscodevim extension is installed?
Another solution is
Click the "Gear icon" -> Keyboard Shortcuts->type "esc" or "Escape" ->
find extension.vim_escape -> edit by click the pencil icon or right click choose change keybinding
->type you desired key and ENTER
Set the Caps-lock to act as Esc in your settings
Post this in your keybindings json for vscode (Ctrl-K Ctrl-S -> open the JSON from the icon on the top right corner):
{
"key": "capslock",
"command": "extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl"
},
If you are looking for a system wide tool, you might be interested in keyd https://github.com/rvaiya/keyd. You can avoid this setup. The readme has an example on how setup caps lock as both ctrl and esc.
Ubuntu solution
First make sure you swaped escape with capslock like: source
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']"
Then inside VSCode press ctrl+shift+p search for Preferences: Open keyboard Shortcuts (JSON) (it will open keybindings.json) and paste:
{
"key": "capslock",
"command": "extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl"
},
{
"key": "escape",
"command": "-extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl"
}
Reload VSCode and you are good to go.
Windows solution
Install AutoHotkey
Go to AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\
Create a file caps_to_esc.ahk and insert code:
#IfWinActive ahk_exe Code.exe
Capslock::Esc
Esc::Capslock
#IfWinActive
Save, run the file and you are good to go.

Shortcut for Sublime Text 3

In my Sublime Text 3, the shortcut Ctrl+A moves cursor to the front of line as expected. However, Ctrl + E does not move cursor to the end of line. Then, I find out that this works: Command+RightArrowKey on Mac.
Anyone knows why Ctrl+E does not work as expected in the official shortcut documentation? What command shall I configure in the keybinding map?
My User key binding is very simple.
[
{ "keys": ["shift+space"], "command": "move", "args": {"by": "characters", "forward": true} },
]
When keys don't do what you expect in ST3 it's a good idea to install FindKeyConflicts
Install it through Package Manager and it'll help you work out why things aren't doing what you thought they should
The shortcuts listed are specific to the platform and the version of the Sublime Text. Here is the list of all the shortcuts, there is also a comparison chart here. Further, if you are getting started with Sublime Text3 this link might prove helpful.

Keyboard shortcut to show/hide tabs and status bar in ST3 OSX

How do I set up a keyboard shortcut to show/hide tabs and the status bar in Sublime Text 3?
At the moment I have to go View->Show/Hide Tabs. I'm using OSX. I have for instance
{ "keys": ["shift+space"], "command": "move", "args":
{"by": "characters", "forward": true},
in my key bindings user file which I set up (thanks to this answer!) to move the cursor one space forwards by pressing shift and space, and ideally I'm looking for something similar to show/hide tabs and the status bar.
In the ST console, enter sublime.log_commands(True). Then execute the command through the menu as normal. The command being executed (with arguments if applicable) will be displayed in the ST console. You can use the information there to create a key binding to the appropriate command.

Resources