How to jump to file explorer in VS Code? - vim

Using the VIM extension for VS Code is there a key command to jump to the explorer pane and then back to the work window?
I cannot find anything in the docs.
I'm hoping there is something like my Control+N binding for NERDTree which lets me open the file viewer, pick a file and then close it.

I am not familiar with NERDTree, but I think Ctrl+Shift+e does what you are asking in vs code. Alternatively Ctrl+p may be an alternative? You could look at
linux keyboard shortcut for more reference.
The link is also available in Help > Keyboard Shortcut Reference
EDIT: I'm adding the equivalent shortcut for Mac OS since it's different layout. However, I don't use Mac OS.. So I add this without being able to confirm :
Shift+Command+E
Mac OS Keyboard shortcut for VS Code
Windows keyboard shortcuts are very similar to linux ones. So, I'll just include the link to windows shortcuts doc here. Windows Keyboard shortcut for VS Code

Just my two cents:
If you are using the Vim extension for VS code you can add this to your settings.json file:
"vim.normalModeKeyBindings": [
{
"before" : ["<leader>","a"],
"commands" : [
"workbench.view.explorer"
]
}
]
The exemple above uses <leader> + a while in normal mode to display the file explorer where you can navigate the file list with j and k. Pressing ENTER will open the file under the cursor and close the file list.
To set up a leader key just add in your settings.json:
"vim.leader" : "," ,

In addition to Santiago's comment, you're able to open a file in a new tab from the explorer (Cmd + Shift + E) with Ctrl + Enter for MacOS. I'm not sure about Windows or Linux.

If you want to go to a file with VIM in VSCode:
Enter Normal Mode (Esc)
Place cursor over file you want to jump to, e.g. between the quotes - "../models/postMessage.js";
Press lowercase gd - Go to definition

Related

JupyterLab keyboard shortcut to duplicate cursor

I can hold alt then click and drag in a line to create a line of cursors. However, I'd rather do this with a keyboard shortcut (e.g. alt + up creates a new cursor on the line above the current one). I don't see anything about cursor duplication in the Keyboard Shortcuts file or the command palette - does this mean there is no way to set up a shortcut for this? If not, what command do I need to bind to do it?
Does Ctrl+Alt+Click work? Just a quick tip, I do not think simply using the keyboard is possible to do what you want to achieve.
#3992 Support keymaps in notebook cells
#1362 Support Vim Editing Mode in Cells
Relevant sources:
Multi-cursor editing in Jupyter Lab

how to change editor behavior in intellij idea

I have installed IntelliJIdea 14.0.2 just now. I do not know its default editor but it is opening my source files in vi option now. So, not letting me do default action like Ctrl + v, Ctrl + d which was present before and I used to like it.
So, how to change this behavior like present in sublime - editors?
disable below option in menu bar.
Tools -> VimEmulator(Ctrl + Alt + V)
If you don't need vi keybindings, uninstall the IdeaVIM plugin.
If you don't want to uninstall vi, you can either turn it off, like #redredtokki states (Tools > VimEmulator), or
Change the Ctrl-X and Ctrl-V keys in File > Settings
under: Editor > Vim Emulation:
Change the column on the right from "Vim" to "IDE".
If you wanna use vim and also shortcuts like Ctrl+C/Ctrl+V/Ctrl+X, you may redefine the shortcuts as IDE shortcuts in:
File-->Settings-->Other Settings-->Vim Emulator

Script to copy text in vim and paste to different window

I've been trying to get a script working which would copy a line of text from vim, delete the line, then paste the line to another window. So far I've tried implementing the script with Autohotkey (on Windows 8) and Autokey (on a Ubuntu VM I run). Here's what I've put down:
On Autohotkey:
!^p::
SendRaw "*yydd
SendEvent !{tab}
SendPlay ^v
On Autokey (linked to Ctrl+Alt+p):
keyboard.send_keys("\"*yydd")
keyboard.send_keys("%{TAB}")
keyboard.send_keys("^v")
In both instances, the Vim commands (yank current line to system clipboard, delete current line) work properly, but the scripts fail to switch windows for the paste, and instead execute a Ctrl-v in vim.
Does anyone know what I would need to change in order to get the Alt-Tab functionality working?
Sending the raw Alt + Tab keys doesn't work, as application switching is a core Windows function. In AutoHotKey, there's the AltTab special command (look it up in the help), or better use the WinActivate command, as AutoHotKey seems to still have issues with Alt-Tab on Windows 8.

Vim format source code from Visual mode

watching a screencast (can't link it since you need to have a peepcode pro subscription) I've seen a developer indenting his source code (a ruby file) graphically using the visual mode inside vim. He did the following steps: press "v" selecting lines and then pressing something else I didn't get (because there is no representation of what's being pressed on the keyboard), then he got the whole source perfectly indented, without the need to write something on the command line.
Is there a plugin you know to do it that way from visual mode?
You can press = in visual mode to automatically indent your code.
Or you can use > and < in visual mode to change the indentation level
of the selected code.
This plugin does exactly what you want: https://github.com/Chiel92/vim-autoformat.
That would be V(motion)=.
See :help = for details.

How could I get this Vim binding to work?

qnamebuf plugin description says:
<S-F4> opens an explorer from the current working directory showing all files which are not in a hidden directory (one that starts with '.')
I'm not very good with Vim, but I imagine S-F4 is a capital S followed by F4. However, when I press S, I find myself in insert mode, and pressing F4 after this, just adds an F4 in the window. What should I do to make the command work? I am running gVim under Windows.
The S stands for Shift. So try pressing Shift-F4.

Resources