How do I customize vim commands on VS code? - visual-studio-code

I have installed the vim extension in VS code. I like Vim's features but I don't want Vim to overwrite overwrite all my previous VS code key bindings which I felt comfortable.
I want to use vim though, but not completely. It'd be better if I could use the VS code commands as well. Something like Ctrl+K, Ctrl+O doesn't work while using Vim. And I feel that Ctrl+S is better to use than :wq. How can I make these(my existing) commands work while still using Vim?

Related

How to add language to visual studio code

I want to be able to use vscode for code golfing in esolangs, but I don't see any way to just simply add a language. I have an interpreter, how can I add it as a language? Everything I've found has either been about changing python interpreters, or integrating autocomplete, eslint, etc. etc. which I don't need for writing brainfuck or golfscript.
I don't want to create a vscode extension just to avoid manually running it with the interpreter from the terminal.
I did get it working by changing the interpreter and extension for a language I do not use, but that is a very stupid solution.

How do you avoid key binding collisions between VS Code and vscodevim?

I have some shoulder pain that I am trying to get rid of by using vscodevim.
My biggest problem with vscodevim so far is that is sometimes collides with VS code shortcuts. For example I often save all my files with Ctrl+K S. But with vscodevim enables, instead that key combination does something else.
I feel tired about the prospect of having to build a configuration with my own key VS Code key bindings, that don't conflict with vsvim. I hope there is a better solution.
So I ask you, my better knowing colleagues, how do you solve this problem?
There is no easy way out for avoiding conflicts between vscode shortcut and vscodevim bindings. I suggest you to use vim keybindings instead of vscode shortcuts wherever possible. Vscodevim can prove to be a good gateway to vim provided you are open to relearning how you use vscode.
Instead of building your own configuration that doesn't collide with vscodevim you could redirect the effort in finding a way to do the same thing in vim. You can search web or use vim help.
Vim help is really comprehensive and easy to read. If you have vim installed you can use :help or :h followed by a specific subject, for example if you need to read about navigation type :h navigation.
Now you have two choices and I will try to use example you provided i.e. saving a file :
Use bindings available for saving file in vim.
Vim provides so many shortcuts just for saving and quitting files, in vim try :help write and :help quit to know more. Many of those shortcuts works in vscodevim too.
To save file :
:w to save a single file
:wa to write all buffers (in vscode all modified files).
Remove the bindings from vscodevim and use vscode shortcut.
You can delegate the key combination back to vscode. I suggest you do this only if there is any vscode shortcut that is absolutely necessary for you and it conflicts with vscodevim as doing this may result in some related vim bindings to not work. To know what Ctrl+k does in vim type :h ctrl-k in vim.
If you want to use Ctrl+K S for saving file do following:
Open vscode settings and search for vim handlekeys or directly open vscode's settings.json:
add following "vim.handleKeys": {"<C-k>": false}
I don't know if this a better solution but I was in your situation and tried different ways to solve it. Finally I found it was much easier to use vim keybindings than trying to coerce vscodevim.
I set up a "toggleVim" keybinding, like so: https://stackoverflow.com/a/61652769/1054322
When I want to use a hotkey that clashes with vim, I just turn off vim.
I installed "vscode neovim" instead of "vim".
Open the vscode setting, you can search "vscode-neovim: Use ctrl keys for insert Mode", disable it.
So you can use "ctrl k+ ctrl c" to add a line comment in insert mode. Also other vscode "ctrl" keys could be used in this mode.

How do I run an external command on the current selection in VS Code?

I'm currently switching editors from Vim to VS Code. One feature I like in vim is the ability to run an external command on a region of text (the :! command). I've been unable to find an obvious equivalent in VS Code.
Is this feature available in VS Code? Or is there an extension that provides it?
(As a more general question, what's the best way of finding out things like this? Is there a website or anything that describes how to do common tasks from other editors in VS Code?)
For the record, VSCodeVim allows you to do the same thing.
Having searched some more (the key term is "filter the selection") I found the Filter Text extension, which does exactly what I want.

Emacs commands hints and history

I just reinstalled Emacs from scratch and I am missing a extension that showed hints
about the commands i am typing in the command line. It also showed a history of what i used before.
It looked something like:
M-x list-p {list-packages} {example-command} {example-ex1} {example-ex2}
I have just a basic setup with prelude right now.
I really need this extension. I learned a lot from it.
It's maybe ido-mode (M-x ido-mode) or a bit different emacs-helm

Emacs inside of gedit?

After years of experimentation with editors, the fact is I prefer them as minimal as possible. I never use fancy features and the full-feature IDE's become bloated, heavy, and slow. Of course, when I do something that pretty much requires a specific IDE (like Android dev and Eclipse) I have no problems using it. But most of the time, I use gedit for programming.
However, I like many Emacs commands, and I want to use them occasionally. Is there a way to embed Emacs inside of gedit? For instance, I envision pressing alt-q (or whatever combo) and Emacs mode is enabled, and from then on all my key presses in the current tab do Emacs commands. I press alt-q again, and it turns off. This would allow me the best of both worlds. Anything like this exist, or do I need to write this plugin myself?
No.
I've seen discussion of embedding of Emacs in other applications in the past, and the consensus is that even that's not feasible, let alone what you're suggesting.
You'd be better off identifying what gedit does that makes you want to use it instead of Emacs, and extending Emacs to make it do that, too. (There can't be that much --- gedit doesn't do much.) The extra features can just sit there and wait for you, and you'll find it easier to locate and use them if you're comfortable in Emacs-mode already.
(On top of all the other advantages of Emacs, you gain the ability to use the same editor you use in a windowed environment on the terminal --- a huge advantage.)
Or maybe yes . . .
You can use the External Tools plugin of gedit (look for it in Preferences). Add a new command, bind it to the key you want, and use this script:
#!/bin/sh
FILE_NAME=$GEDIT_CURRENT_DOCUMENT_PATH
emacs $FILE_NAME
If you want it to open in the currently-running Emacs, replace emacs with emacsclient, and add the following to your .emacs:
(server-start)
This is kind of backward. Why don't you just use Emacs and stay away from all the extra bells and whistles? It'd probably be easier to coax emacs to emulate gedit than the other way around.
If gedit (a) can be scripted to launch another application with the current file as an argument, and (b) will notice if the file is modified on disk and offer to reload it, then you would have a workaround.