AltKeyboardModes
Additional keyboard modes to Visual Studio code editor windows. A bit like in Vim, you can map keys to commands in these new modes.
The extension adds new editor commands like goto next identifier, pop browse context, goto constructor etc.
How to use
- Press Alt+Space to switch to Alt1 mode (or press twice left Shift)
- Press Shift+Space to switch to Alt2 mode (or press twice right Shift)
- Press Space to go back to normal mode
- Press Enter to switch between Alt modes
Using alt modes makes some common tasks easier. For example if you want to surround current line with an if
block, press
Shift+Space
(Activate alt2 mode)
d
(Select current line)
:
(Surround with... + Go back to normal mode)
instead of
Home
(Go to the beginning of current line)
Shift+End
(Extend the selection to the end of current line)
Ctrl+k
, Ctrl+s
(Surround with...)
If you want to execute the same command multiple times, just type the muliplier first: e.g. 4i
in Alt1 mode moves the caret up by 4 lines.
Change log
-1.9.8
Command mappings
Quick review panel
To review the currently active Alt mode's command mappings press F4. It pops up a quick view panel.
- Press Esc to close the panel
- Press Enter to open the mapping settings page
- If you press any key the given entry starts blinking in the panel
- Press Ctrl+F to activate the filter
- Press Ctrl+C to take a screenshot of the control and copy it to the clipboard
Settings panel
To customize the bindings press both Shifts same time (Or press Enter in the review panel) The Alt1/Alt2 settings panel will be opened (Tools->Options->Alt Keyboard->Alt1/Alt2 schema)
- Right click menu to save, load settings. Mode mappings can be persisted into simple pipe delimited files. The mapping can be set to its default any time.
- CTRL+Space to pop up the completion window, TAB or Enter to commit the selection, Esc to close the completion window.
- To specify a composite command, use ; (semicolon) to separate the individual commands. e.g.
Edit.LineStart;Edit.LineEndExtend;Edit.MakeUppercase
will convert all the characters in the current line to uppercase.
New VS commands
State transition commands
- AltKeyboard.Alt1Mode
- AltKeyboard.Alt2Mode
- AltKeyboard.ToggleAltMode
- AltKeyboard.BackToNormalMode
C# specific commands
- AltCommands.Next/PreviousIdentifier
- AltCommands.Next/PreviousName
- AltCommands.GoToConstructor
- AltCommands.GoToContainingSymbol
Goto providers and commands
- AltCommands.Next/GoToPendingFile
- AltCommands.Next/GoToOpenFile
- AltCommands.Next/GoToBreakpoint
Regex based navigation commands These commands find the next/prev match of the given regular expression and may extend the selection as well. The regexes can be set in Tools->Options->AltKeyboard->General
- AltCommands.Nav1[Next|Prev|NextExt|PrevExt]
- AltCommands.Nav2[Next|Prev|NextExt|PrevExt]
- AltCommands.Nav3[Next|Prev|NextExt|PrevExt]
- AltCommands.Nav4[Next|Prev|NextExt|PrevExt]
Block navigation command. Continuous series of significant lines of code considered a block.
A code line is insignificant if it is empty, commented out or consists of only punctuation.
- AltCommands.StartOfBlock
- AltCommands.EndOfBlock
- AltCommands.StartOfBlockExt
- AltCommands.EndOfBlockExt
Hump (subword) navigation commands
- AltCommands.NextHump
- AltCommands.PrevHump
- AltCommands.NextHumpExt
- AltCommands.PrevHumpExt
Line selection commands
- AltCommands.SelectLineDown
- AltCommands.SelectLineUp
Misc selection related commands
- AltCommands.WidenSelection Widening selection by 1 char on both ends
- AltCommands.ShrinkSelection Shrinking selection by 1 char on both ends
- AltCommands.ToggleSelectMode Switching between stream and rectangular selection mode
Other Commands
- AltCommands.PopBrowseContext This command is optimazied away from VS2015/2017 C# service. More info about this handy command
- AltCommands.ToggleNavBar Switching on/off navigation bar in the editor
- AltCommands.ToggleSplitPanel Switching between horizontal and vertical arrangement of the split panes in the editor. In case of a 16:9 screen the default vertical layout is not always ideal
General Settings
Global Alt mode If it is set all editors share the same mode. (Eg. if you switch to Alt1 mode all editors will be in Alt1 mode)
Log command execution Executed commands are printed out in the output window
Override GOTO commands If set to true Goto Members session starts always in current document context. The other GOTO commands use the whole solution context. Credits: https://vlasovstudio.com/visual-commander/commands.html
Known limitations
This extension was tested against the C# editor. Theoretically it should work same way with other editors but I have no experience. I found the following issues
- It looks Resharper forcibly captures
;
and $
characters If R# is enabled commands which are mapped to these chars won't be executed. (C#)
- Read-only peek definition views are not supported The mapped commands in Alt modes won't be executed at all