8 ms·
VSCode-Neovim: Use embedded Neovim in VSCode without emulation
- WesSouza 4y agoBut can I embed VSCode on Neovim? Yeah, didn't think so.
- deleted 4y ago[deleted]
- jamesappledev 4y agoThat's pretty much what coc.nvim is
- mplanchard 4y agoI used to use this before I switched away from VSCode for greener pastures. It was far and away the best option for vim editing. It’s great because you can still make use of any neovim plugins you have without needing extra VSCode extensions.
- drew-y 4y agoWhat are your greener pastures?
- dcow 4y agohelix is pretty nice if you’re willing to challenge your traditional vim editing model. vim is action -> selection. helix is selection -> action. Beyond that helix feels like a modern vim. LSP natively supported. DAP as well. Very little configuration and bootstrapping to wade through.
- toastal 4y agoWhat does that shift in paradigm give you over Visual Mode in Vim?
- SoraNoTenshi 4y agoMy 2 cents to this as a helix user. 1. it's just nice to see your selection before u do any action. 2. There's not benefit to the new model, either you like it more or like it less, why does everything have to give a benefit? Maybe it's just about the preference. 3. Helix requires less than 50 Lines of TOML to configure, to me this is well worth it, as with neovim, i easily needed like ... 300 Lines of Lua code? Something like this.
- mplanchard 4y agoSwitched to emacs via doom emacs about three years ago and haven’t looked back! I was a big vim user back before VSCode, so I’m happy being back in my obscure editor hole.
- doomrobo 4y agoWould love to see if people have a good experience with this. The only thing keeping me on neovim is the ergonomics of my config. If I can have that, PLUS the discoverability of all the LSP features, hovering, consolidated error messages, etc. without it breaking all the time, I would switch in a heartbeat.
- Jenk 4y agoBeen using it for a couple of years. No problems. You don't get the "absolute fullest" (neo)vim experience because you don't get the buffers/panes like you do in nvim though.
- eric-hu 4y agoI actually do use pane commands from time to time. ctrl-w s : will split horizontally ctrl-w v : will split vertically Commands work, and I just tested buffers specifically. I can type :buffers and I see a list. I was able to get vscode to switch tabs with :b 209 (I don't normally inspect buffers this way, but it's integrated and it works).
- bobbylarrybobby 4y agoI find that on the whole it's much speedier, albeit a tad buggier, than the “official” vim extension. I think in another year it will be more or less perfect. If you're talking about keeping your Neovim config: yes, due to the Neovim extension using the actual Neovim program (this was one of the new Neovim features: it includes a vim server that processes keystrokes and sends updates for use in a different UI). So it has no problem reading your vim config at startup.
- dbalatero 4y agoI don't use VSCode, but if you use this plugin or the other Vim plugin for VSCode, make sure to put it in its own thread so it doesn't compete with other blocking tasks and slow down your editor motions. See "Affinity" docs here for putting it in its own thread: https://github.com/vscode-neovim/vscode-neovim#installation https://github.com/vscode-neovim/vscode-neovim#installation
- satvikpendem 4y agoThis must be a new option, hadn't seen it before. Thanks!
- dbalatero 4y agoIt's new within the last year for sure! It's also marked "experimental" and I think therefore not heavily advertised, but IMO it's also necessary for something like Vim motions that need to move at the speed with which you type…
- asabla 4y agoOh snap! Been more and more annoyed lately about just this. Thank you for sharing!
- cassepipe 4y agoDoes that mean that I don't have to learn how to use VScode at all ?
- capableweb 4y agoPersonally, my problem with trying to use Vim keybindings in VS Code is not about the motions of moving around/editing the code itself, but everything else. You end up in plenty of situations where you have to resolve using the mouse because you ended up on some sub-page or whatever, where you either need to resolve using the mouse or keep pressing Tab until you get to where you want to go. Installing plugins is one good example of this, where even if you use a Vim plugin (or this, it seems), you still need to resolve to using the mouse/Tabbing to actually install the plugin itself. While with Neo/Vim itself, you never need to reach for the mouse, because the entire thing, not just the editing/writing, is meant to facilitate keyboard-only usage.
- Tyr42 4y agoI guess I am the target market. I don't mind using the mouse when I'm not in the "flow" of editing. Even browsing code, scroll wheels are pretty expressive, and clicking to jump to definition is fine. Ok not typing, so I don't need to keep my hand on the home row. But the actual editing doesn't use the mouse.
- eric-hu 4y agoIf you have the proper jump to definition set up, vscode-neovim actually has a keybinding (that matches vim/neovim) gd (go to definition) You'll also like gh (peek definition)
- wilsonnb3 4y agoperhaps onivim would be a good VSCode alternative for you, I think they have a mode like the browser vim extensions that labels everything on screen with a key you can press instead of clicking. https://onivim.io/ https://onivim.io/
- nulld3v 4y agoOnivim is no longer being developed :(
- satvikpendem 4y ago
- pacomerh 4y agoTo me the greatness of using something like neovim/vim is that you don't have to use the mouse. This I don't know what's good for...
- satvikpendem 4y agoGood for people who like the ergonomics of VSCode (one-click plugin installs, everything simply "just works" out of the box) with the ergonomics of Vim (modal editing, speed).
- dbalatero 4y agoThis. I'll go to VSCode from Neovim kicking and screaming, but frankly VSCode + a good Vim plugin is the pragmatic choice for most people out there looking for a Vim-like editor.
- stu2b50 4y agoThe advantage of Vim is efficiency and speed. The disadvantage is that it has a longer learning curve. For something like editing text, as a programmer you do this endlessly - it is absolutely worth it to be ruthlessly efficient at this, even if you have to pay effort learning it. But for, say, installing a plugin in your text editor... that's something you do a handful of times a month. The mouse is much more adaptable and easy to use, even if you give up accuracy. This way, you can be efficient at editing text without having to learn keybindings for a bunch of misc things that you do rarely.
- mewse 4y ago> The advantage of Vim is efficiency and speed. The disadvantage is that it has a longer learning curve. I'm not disagreeing with this comment all, just throwing my anecdata at the somewhat squishy "longer" word in that sentence. For me, I went cold-turkey with vim (my employer wanted me coding on both Mac and Windows at more or less simultaneously; I figured it would be a useful investment of time to learn a single set of hotkeys that I could use on both systems and get into my muscle memory, rather than trying to keep Xcode hotkeys and Visual Studio hotkeys straight in my head) I stopped using literally any other text editor or IDE either at work or at home, just to try to learn vim as fast as possible, and spent a bunch of recreational time playing VimGolf. As I'd expected, it was catastrophic for my productivity initially, but I reached a basic proficiency within five days; I got back to my normal development cadence quickly enough that my lead didn't even notice I had taken time to teach myself to use a "difficult" text editor; I just had one week where I was slightly behind schedule, before catching back up and getting ahead during the following week, where my skills improved even further. It definitely is a longer learning curve before you can say that you've "mastered" vim than most other editors. But you can reach a basic competence equivalent to other (non-emacs) text editors pretty quickly; it's just that there's still a lot more useful functionality you can learn after that point.
- vukadinovic 4y agoI used VIM plugin until now, was happy to see this. However, tried installing it on top of neovim 0.9.0-beta and VS code complains that the version nees to be 0.5 or higher... switching between modes worked but moving (jkli) didn't. So gave up trying to install it. Might try later looks interesting
- barefeg 4y agoI love neovim but I don’t have a good replacement for the git plugin of vscode. I haven’t found my way to replicating that experience in neovim. I tried lazygit but I find the diff viewer hard to understand and navigate. Diff view (https://github.com/sindrets/diffview.nvim https://github.com/sindrets/diffview.nvim) might be it, but I haven’t made the time to install a newer version of git from source (Debian…)
- christophilus 4y agoI'm the same. For the most part, I use a nice terminal git diff (I forget which-- not in neovim), and I hop around in neovim based on what I see there. I do sometimes open Codium just to navigate a large diff, and it always makes me a little sad.
- petepete 4y agoSimilarly, I use diff-highlight 99% of the time because it works flawlessly with all of git diff's arguments (including --word-diff) but break out Meld for big content-heavy changes. https://meldmerge.org/ https://meldmerge.org/
- minusf 4y agohave you tried fugitive? the vimcast videos about it can be life changing.
- aussiesnack 4y agovim-fugitive is ergonomically great for routine stages and commits. DiffView is good but there's no point denying GUI diff viewers are better than text ones, so I use one (meld or sublime-merge), which does mean launching a separate tool. That's fine for my limited uses (quick visual overviews, or fixing merge conflicts).
- emerongi 4y agoGitsigns was good enough for my workflows: https://github.com/lewis6991/gitsigns.nvim https://github.com/lewis6991/gitsigns.nvim Besides showing the git signs in the gutter, it can do staging, diffing, navigation between hunks, line blame, can show deleted lines etc. If you have more advanced workflows, it might not be enough though. I use lazygit quite often as well.
- sblom 4y agoThis has caused me to realize that I need to replace my old model of vi: > command mode has primacy; insert mode is a time-bounded special case with: > insert mode is every other mundane editor; use the Esc key to enter the matrix (i.e. command mode)
- jchook 4y ago> Command mode I think you mean normal mode.
- dcow 4y agoI tried this plugin a few years ago. It was neat but ultimately buggy and not ironed out enough to use daily. To people who currently use it, has it improved noticeably?
- eric-hu 4y agoYes, it has. I've used it for years as well, and I think I know the bugginess you're referring to. Some time back, it required Neovim 0.5.0 or 0.5.1, and that wasn't yet in the official Neovim homebrew package. This was actually documented on the vscode-neovim homepage, but it was easy to miss. Back then, I used a custom homebrew tap to get the proper Neovim version installed, and the plugin mostly worked. Occasionally the editing context would get messed up, and still does. I've found that changing tabs inside VSCode resets the neovim context, and that's a nearly-instant fix for most issues I see now. It also works with the default version of Neovim from homebrew. No more custom tap needed.
- dcow 4y agoI think I actually built neovim from source when I was testing it out. Either 0.4 or 0.5, yeah. I think the lost context was frustrating IIRC and I didn't know that switching tabs fixed it. I just got frustrated and opened up real nvim when that happened.
- pacavaca 4y agoI remember trying neovim with Atom a while ago. At that time I realized that me using nvim it's not just about motions/plugins/no mouse, etc, but rather the whole terminal experience. For example, I rely heavily on tmux for splitting my screen whichever way suits the current task best and then, I may spontaneously open nvim in some of the splits or run other CLI tools. This experience is not the same with the CLI built into vscode or any other IDE.
- CalChris 4y agoI have used VSCode-Neovim on OSX since roughly NVIM v0.5. It is quite simply the best vim environment I've ever used and I've used quite a few. I date myself back to vim, back to vi and even to TECO. I pair this setup with the clangd LSP extension which makes it even more awesome. This is editor heaven. However it isn't perfect, yet. Command mode is still a work in progress and I use command mode a lot. Navigation with the space bar screws up enough that I've switched to the arrow keys (which are smaller). A few others but I haven't checked to see if they're fixed already. VSCode-Neovim is actively worked on and gets better with each release.
- fire 4y agoMy biggest complaint is probably that it doesn't support overlay or popup windows, which makes it impossible to use plugins like WhichKey[0] and such, which I like on normal neovim because I'm a scrub and don't know vim hotkeys by heart 0: https://github.com/folke/which-key.nvim https://github.com/folke/which-key.nvim
- krono 4y agoWhenever I didn't know how to do something or suspected there'd be a far more efficient way to go about it, I'd look up the magic words or keys to use and write them down. Limiting this cheatsheet to just one side of an A4 sheet kept it usable and forced me to rewrite it every so often - every next iteration leaving off all the commands I had been checking back often enough for that they had finally stuck. Completely unsolicited, but hopefully useful advise nevertheless :)
- LinXitoW 4y agoThe beauty of the whichkey/space menu is that you can both learn shortcuts AND find new ones (they're grouped by domain) AND find old shortcuts you rarely use. It's the antidote to most sophisticated editors worst problem, that there's a bajillion commands scattered around a million menus, many of which are not even remotely intuitive.
- fire 4y agoyep, that's why I want it
- ilovecaching 4y agoYou might be able to convince me that for certain languages and tasks, a Jetbrains editor is better than using a plugged up Vim or Emacs. And the up front cost is well known, and their corporate model is easy to understand. You’ll never convince me, however, that Microsoft’s embrace, extend, extinguish partially proprietary editor that uses the same LSPs as any other LSP client should be used by anyone. I wouldn’t touch it with a 100 foot pole. There are turn key solutions for both Emac, Vim, and Neovim. They can all talk to LSPs, have DAP clients, fuzzy finders, file tree explorers, project managers, remote editing (terminal editors are by nature the ultimate remote editors). Why isn’t he world would you put neovim inside of VSCode when you could just use neovim directly via GUI or terminal.
- satvikpendem 4y agoDon't, no one's forcing you, but many if not most people prefer VSCode over neo/vim, based on usage stats. For those of us that do, we like Vim's modal editing but not its setup process.
- CollinEMac 4y agoI use the regular vim extension in VSCode. How does this compare to that?
- eric-hu 4y agoDay and night. I haven't touched the regular vim extension in years, but its vim compatibility and feature set depends on the extension author. This plugin starts up neovim as a backend server and sends the file and keystrokes to that. It's not emulation, it's actually Neovim.
- snarfy 4y agoI don't use this extension, but I have used the 'vscodevim' extension for many years now. I forget all of the settings I changed to make it work for me, but it's mostly usable as a vim replacement now. I needed to set 'use control keys' or something like that, so I can use Ctrl-[ instead of ESC to enter command mode, something I've done since Vim 2.0 days (and before that in Elvis). I also override vim bindings for Ctrl-X, Ctrl-C, Ctrl-V, (cut/copy/paste), Ctrl-Z, Ctrl-Y (undo/redo) so I can use vscode for that behavior instead. I'll also use the normal vim commands for those also (like yy, p, etc). Best of both worlds I suppose. My only gripe with this approach is undo/redo stacks can sometimes get lost between vim and vscode handling it. There is a similar extension for Visual Studio which has never lost the undo/redo stack like the vscode extension does. Is any of this any better with the newest vscode-neovim? I tried vscode-neovim a while back and had go back to vscodevim after having problems.
- cutler 4y agoI reverted to Vim after trying NeoVim for a few weeks simply because a lot of Vim defaults had to be chased-down and configured just to get basic Vim features in NeoVim. NeoVim also requires messing with a ton of config files compared with Vim so no thanks.
- colordrops 4y agoHmm, I used vim for nearly a decade then switched to neovim a few years ago and it was pretty much seamless. I've only got one config file for neovim that still works for vim, so your info on that is just plain wrong. What defaults did you have difficulty with? All my settings were mostly the same.
- alwillis 4y agoHmm, I used vim for nearly a decade then switched to neovim a few years ago and it was pretty much seamless. Same. Neovim just enables most of the settings almost all Vim users turn on anyway; it’s not a dramatic change by any means.
- n8henrie 4y agoWeird, I've had exactly the opposite experience. Neovim seems to have much more usable defaults IMO, I was able to decrease my config size a fair amount when I stopped trying to maintain a vim-compatible config file, in large part because of the settings that were already default in nvim.
- krono 4y agoYour single `.vimrc`-style config file should just work, NeoVIM just looks for it elsewhere. Most other differences are config defaults, the majority of which I suspect you have manually added to your current VIM config anyway. Here is a detailed list of all the differences on the NeoVIM docs: https://neovim.io/doc/user/vim_diff.html https://neovim.io/doc/user/vim_diff.html It's totally fine if you simply prefer VIM, of course.
- metta2uall 4y agoAlso check out the VSpaceCode extension bundle - it reduces the need to use the mouse, but unfortunately not completely.
- jchook 4y agoThis seems like a lot of work to ultimately have a Frankenstein monster. Just use NeoVim. Name one reason why you need VSCode.
- toastal 4y agoBonus: Neovim isn’t phoning home to Microsoft nor does it try to bifurcate communities on using proprietary plugins.
- satvikpendem 4y agoI don't have to spend a bunch of time configuring VSCode, I can simply do a one-click install for plugins, and I can focus on the editing interface with Neovim.
- jchook 4y agoThere are some outstanding out-of-the-box solutions for NeoVim. AstroNvim comes to mind https://github.com/AstroNvim/AstroNvim https://github.com/AstroNvim/AstroNvim
- typon 4y ago* If you want 50ms latency on every interaction with the editor * If you want to send telemetry to Microsoft * If you want slow fuzzy search for massive codebases Plenty of reasons
- 0x008 4y agoBest out of the box python experience out there. No need to configure anything. Company policies. ("we all use the same editor")
- bitwize 4y agoFor when you hate Emacs so much, you need to form a Voltron of non-Emacs editors to fight it with.
- a-b 4y agoWhile I'm missing global mode my choice would be vscodevim.vim (1), mainly because it supports VScode in-browser mode such as github.dev and gitpod.io (1) https://open-vsx.org/vscode/item?itemName=vscodevim.vim https://open-vsx.org/vscode/item?itemName=vscodevim.vim
- stevebmark 4y agoThe Vim mode paradox: If you enjoy working in Vim mode in other editors, you probably aren't familiar enough with Vim functionality to justify your use of Vim. Not having q/ nor q? is already enough for me not to want to use this. VSCode's multiple cursors is generally more powerful than Vim's nasty small imperative commands you have to glue together to try to get efficient editing.
- jatins 4y agoCould be Baader–Meinhof phenomenon but I feel like Vim is having a resurgence due to lots of streamers and youtubers using it. I personally started using Vim bindings in VSCode recently due to wrist pain issues and have been geeking about it a bit. Though there is still a fair bit of cognitive overhead for basic editing operations that were second nature previously.
- swah 4y agoI think so. Also "in real life", in 20 years around coders, I only met 1 Vim user and 0 Emacs users. Everyone else has always been running the IDE for that language, or something like Notepad++...
- Kwpolska 4y agoThe discussion of Vim visual mode selections being separate from VSCode selections is concerning. What kind of selection is produced if you make a selection using the mouse? Are there any actions where you can end up with the wrong type of selection?
- rendall 4y agoOk, I tried this out. Setup is a bit of a chore but not difficult, mostly making sure that the correct version of neovim (> 8) is installed. I have only one bit of feedback, but for some reason it's a deal-killer for me. Vim is my go-to text editor and VS Code with vim emulation is my go-to IDE, so I was excited to try. The vim emulator puts the `:` command in the status bar on the lower left, quite like vim itself does. Type `:w` and you see that in the status bar. By contrast,the way that command `:` is handled in the embedded neovim extension is that a search window pops up at the top where the commands and files drop-downs are (same place that gets the cursor when hitting ctrl-p). This confused and dismayed me so much that I immediately noped out, disabled the extension and went back to using the emulator. It might also have been dismaying that `w` was not one of the listed commands, only `wq` which is not what I wanted. `w` did work, but I was done. I probably could get used to it, but I'm inclined to jettison things that mess with what I'm used to unless there's a massive value-add. As for now, I pretty much only use vanilla vim and so the emulator is good enough. When I need more power, I open vim either in a separate terminal or sometimes right in the VS Code embedded terminal. I don't really have an intense need for real neovim in VS Code at this point. Finally, I do want to give props to the creator! This is an amazing accomplishment, and I hope that my feedback is not discouraging! If there could be a setting to reflect the commands in the status bar as the vim emulator does, I will be eager to try it out again. But still, great job!
- ossusermivami 4y agowhen I am not in Emacs+evil and I have to open vscode for launching the debugger I use vscodevim, I am not sure why people say it's too limited, it does the job more than allright for me and I tink I use vim keys and motion to its fullest.... sure it doesn't have :map or other commands but as far editing and moving around it work well for me.... as far vscode-neovim i have tried that but it was freezing too often for me (on osx and linux) I would have to restart the plugin extension host or something to get it fixed.... much nicer to have configuration in a .vim file tho compared to json based configuration of vscode-vim I actually enjoy more idea emulation of vim which I think is much more advanced.... but vscode is a good middleground between an editor and ide or at least for my debugging sessions.