loading...

VSCode vs Vim

ben profile image Ben Halpern ・1 min read

Software vs Software (10 Part Series)

1) React vs Vue: Compare and Contrast 2) AWS vs Azure vs Google Cloud 3 ... 8 3) VSCode vs Vim 4) PostgreSQL vs MongoDB 5) OOP vs Functional Programming 6) Computer Science vs Software Engineering 7) Python vs Java 8) Classical CSS vs CSS in JavaScript 9) Ruby vs Elixir 10) Imperative vs Declarative Programming

Your life as a developer depending on what you choose as an editor.

Let's compare and contrast your experience if you go down either of these paths. Feel free to branch the conversation on to other editors but I felt like this is the most relevant debate today.

Discussion

markdown guide
 

My story goes like this: very much in love with Vim in the early 2000s. When I got into Clojure ~2009, I got into Emacs, and lived in it for the next couple of years (I pretty much used it as my OS, running a Twitter client and other things in it). But modal editing is just so much more efficient, so I eventually ended up with Spacemacs (and much later Doom Emacs). Around 2015 or 2016 I got into VSCode, but the sluggishness of Electron apps drives me crazy, so I went back to the roots and now use Vim again.

My current NeoVim setup looks roughly like this (NerdTree and TagBar are toggleable and I don't have them visible most of the time):

neovim screenshot

 

i need to figure out how to set up tag bar. i love vim but i don’t have it set up well to be a great IDE.

 

Maybe you can get some inspiration from my NeoVim config:

github.com/citizen428/nvim-config

it's actually setting up a ctags library that i've had trouble with. although looks like you are using something called universal-ctags instead of exuberant-ctags. i'll give that a try.

I see. Yeah, just brew install universal-ctags and Tagbar and things should just work™. It's their recommend version now:

Exuberant Ctags >= 5.5, or (highly recommended) any version of Universal Ctags which is a currently maintained fork of Exuberant Ctags with many bugfixes, support for many more formats, and proper Unicode support.

If you get stuck feel free to message me here, my DMs are open.

 

VSCode (VSC) and VIM are my two main editors.

I sit within VSC almost all day every day. Editing on multiple devices gets annoying when switching over (Windows/macOS), but there are some plugins to help with that effort (search extension shan.code-settings-sync). VSC is a very powerful editor. Once you have keybinding setup, a few environment configs, and runners, you're good to go. The extension list is ever-expanding, and with that, you're more likely to find a few that really work well for you, or even make your own. Outside of the extensions, Intellisense is my saving grace. I often forget what functions are already implemented (or even the documentation and the argument variables) but that's when VSC is there holding my hand. The majority of work is in VSC because it's pretty on the eyes, integrated terminal for Windows (because no global hotkeys for iTerm2 like macOS) and the ability to work on various instances - even in the browser (see GitHub's new Codespaces?).

VIM is however my go-to editor. If I need things quick done now I run vim not vscode in my terminal to kick things off. Any time I'm remoting into a machine, I run vim. Even when VIM is not there, I install it, copy my dotfiles from GitHub, and continue with my day. VIM is excellent, fast to use - especially when you start understanding the basics - and there is still so much more I don't know about it and have to learn; but there's help with that (duh StackOverflow too). I recommend learning some of the basics in navigation for developers of any kind. Again, back to remoting into other machines, having an editor already there for you taking just a single config file and you're on your way is an amazing tool to have some skills with as a developer. It opens lots of doors, and just like the comments made here (by @wayofthepie ) it's something that can take time doing, but once you get the basics, "[it's like playing an instrument...my fingers just know what to do.]"

Also, I know there are other terminal editors too, if one stands out then pick that one! Whatever makes you the most productive is the best for you and that's really all that matters. Stay safe 😄❤️

 

Intellisense is my saving grace

I'm not a big user of Intellisense, but I find Vim's offerings sufficient (I do use ctags quite a bit too):

vim intellisense

integrated terminal for Windows (because no global hotkeys for iTerm2 like macOS)

The terminal in Vim8/NeoVim is pretty good too, but I don't know if/how well it works on Windows.

 

You can use coc.nvim which brings intellisense of vs code to vim

 

Both VSCode and Vim are great editors with cult-like followings. Both have a great community built around them. For me it comes down to a few things that might not be of any importance to others. This is only my opinion and you're all welcome to take or leave it. First and foremost, I am not a Vim user nor will I ever be. I'm a strong advocate of pairing and Vim is painful to follow while pairing. I can't say the same for VSCode. If pairing is part of your team's workflow, Vim is a no go. In my experience VSCode just works and it doesn't require your pair to mind map to be efficient. I'll take the "slowdowns" that come with Electron apps in favor of all the built-in efficiencies for source control, debugging, and remote development. While the Vim community is large, it's ancient. Being a full stack engineer, I prefer my editor to stay as up to date as the technologies I'm using everyday. That's my two cents.

 

I'm a strong advocate of pairing and Vim is painful to follow while pairing.

I've worked on many teams where people paired in Vim and/or Emacs, what problems did you encounter with that?

For remote pairing I do like VSCode a lot though, Live Share is very nice.

 

Each Vim developer had a custom layout and file tree that made it hard to follow during pairing. Again this is just my experience, but I didn't find much consistency between Vim environments either. There's also the fact that I had no indicator of what was going on when the host would start tapping away at key bindings. I think we've all been there when a Vim developer mistypes a command several times just so they can do it the "Vim way". During these times I would tune out or get frustrated with the inefficiency. I've also had several Vim devs tell me that X plugin is not working so they have to do things a little weird, then run linting/formatting outside as a post process to their normal workflow. Not show stoppers by any means, but IMO unnecessary friction points.

Fair points, thanks for taking the time to respond :-)

I sometimes use VSCode when pairing with other people, partly because Live Share is really good, but also because it's a more "neutral" environment. It also has some really good language server implementations, e.g. for Reason/OCaml. The Ruby one on the other hand is IMHO quite horrible, "Format On Save" with Rubocop enabled is extremely slow.

This is why I bought a license for Onivim 2, it really could become the best of both worlds.

 

VSCode is fantastic for large projects. I need the Intellisense training wheels at all times otherwise I would get nothing done.

Vim is nice for editing one line edits from the terminal or writing out a text file. Can't see myself ever using it for development

 

Out of the box, Vim isn't an environment that's terribly good for development. It does take some work to get it into a state where it's a genuinely good development environment because that tends to be language-specific.

I mostly do PHP, with some Javascript too, and I have, among other plugins, vim-ale for linting in multiple languages, and Deoplete for autocompletion. I also use PHPActor, which not only integrates with Deoplete to provide reasonably smart PHP completion, but also provides numerous refactoring tools of the sort that used to be the sole providence of IDE's.

In short, it can be done, but it's a very personal choice as to whether you think it's worth it for your own workflow. In my case, I have a degree of RSI from a previous non-coding role and it gets aggravated by using the mouse, so my workflow is very keyboard-heavy, and Vim fits that like a glove. I did migrate to Neovim nearly two years ago, but the experience is virtually identical.

 

VSCode for development in local, vim for editing env files in production server.

 

They are both great. Used vscode mainly for about a year and really liked it. Didn't have to do much to get it working for most languages!

But I started getting some back, shoulder and wrist issues around that time. Not because of vscode, but because of how I sat and used my keyboard and mouse.

So I totally changed my whole workflow and setup. Moved to vim (well neovim) and switched to a tiling window manager so I could reduce mouse usage.

I spent a lot of time tweaking my vim setup to get what I wanted for the different languages and tooling I need to use. It's made me much more productive for sure. Not really faster overall - coding is mainly thinking 😄 - just more comfortable in translating those thoughts to code than I was with any other setup before.

It's become kind of like a musical instrument 🤔 I don't have to think much about performing a certain action, my fingers just know and do it.

 

I switched to vim from TextMate over 10 years ago. I love modal editing. I also love modally controlling the whole editor (like opening files and showing/hiding different buffers). I have more trouble learning to hit several keys at once than learning to hit them in series. I do have a few key combos set up in vim that I keep forgetting so I should probably turn them into mappings.

That said I think VSCode is pretty awesome. What attracts me to it most is the powerful intellisense, since I haven’t figured out how to get more robust completion with vim plugins.

I’ve tried getting into VSCode, since I can at least edit text modally with it (although it feels slower), but there’s just too much to set up. Back in 2008 or 09, it took me two weeks of being fairly unproductive to get vim set up well for me. At the time there wasn’t much work to do because of the economy, but right now I have a lot of work to do (in spite of the economy).

 

Vscode wins cup🤾‍♂️🏆🥇
all community support extension and from web development perspective it is beast
 
 

Vim is amazingly powerful - but I can't be bothered to keep a map of key shortcuts in my brain.
VS Code - I might lose some time pointing and clicking, but it requires no extra mental arithmetic.

I can save that effort for creative problem solving. :)

I should add that I do have a level of envy for people who can do the former (including emacs users) - its impressive and I admire it. It's just one skill I've been unable to learn

 

Vim is amazingly powerful - but I can't be bothered to keep a map of key shortcuts in my brain.

I have no intention of convincing you, if you're happy with VSCode keep on using it!

But Vim commands are very logical and consistent, so there's not much remembering to do. For example:

  • foo_bar, with the cursor at the f: df_ will Delete until it Finds an _, leaving you with bar. If you change the d to a c you would Change unTil _, leaving you in insert mode before _bar.

  • variableName with the cursor on N: cw will Change the Word, leaving you with variable in insert mode, whereas ciw (change inner word) will replace the whole name and leave you in insert mode. daw on the other hand will Delete A Word including the whitespace that follows it and you'll still be in normal mode.

Once you learn basic commands, how to efficiently repeat them and the most common text objects you can already achieve a lot without having to remember too much.

 

I always though of i as “inside” and a as “around”.

Those are great mnemonics 😊 I tend to use the terms from Vim's documentation (help text-objects), so people get used to the official terminology:

aw                "a word", select [count] words (see |word|).
                  Leading or trailing white space is included, but not
                  counted.
                  When used in Visual linewise mode "aw" switches to
                  Visual characterwise mode.

iw                "inner word", select [count] words (see |word|).
                  White space between words is counted too.
                  When used in Visual linewise mode "iw" switches to
                  Visual characterwise mode.

hah, i never knew what it said in the help docs. i think i read a blog post once that gave me those mnemonics.

 

Yes, absolutely. cw combined with search and period (repeat last command) is an incredibly efficient way to change over code to new naming. I use this all the time when copying over boiler plate code that has just a few name changes needed and it saves so many frustration inducing mouse moves!

Depending on how many things you have to replace an ex command may be a better choice, e.g. s/old/new/gc.

That said, I recently did a big refactor on the DEV code base that essentially consisted of a case insensitive search, followed by one of 3 recorded macros (df_ for variables, dtL for classes and df- for CSS classes) and copious amounts of .. The macros (@a, @s and @d in my case) made it easier to switch between the different transformations necessary. So it went something like / @a n . n . n @s n . n @a n . n . etc.

 

I think the key with any editor/tool is to learn it well to be more efficient. VSCode is easy to use so it doesn't necessarily force you to learn the hotkeys and get good with it. Vim has a learning curve in order to use it, so it is very much learning by doing and forcing you to get better with it. Customizing an editor like Vim may not be worth the investment in time saved typing, but it may be preferred or a fun hobby for some.

When I code, I am usually not furiously typing away, I'm thinking more about what I want to do and then entering it. I don't believe the editor or using the mouse is slowing me down, I would still want to take my time. Learning the default hotkeys and features is enough for me, so I prefer VSCode.

Not specifically VSCode/Vim, but I'm also a big mouse user (probably due to my PC gaming background), but there is more and more "mouse shaming" that I see going on in the developer community. It has equal priority to the keyboard for me. Sometimes there just isn't a good keyboard shortcut to get to something on the screen which is frustrating and inefficient for me. Tabbing through a webpage is kind of like iterating through all items in an array (O(n)), but clicking on the exact link is like accessing a specific array index (O(1)). At least that is how I think of it. 🤷‍♂️

 

One big thing which seems to be forgotten by a lot of people on both sides: vim is tiny by modern standards for how many features it provides. VSCode quite simply cannot compete here because it uses Electron and has all the baggage that comes with that.

 

If that matters to you, sure. These days the smallest amount of RAM I have to work with is 16GB and I know I'm not the only one. From an absolute standpoint VIM uses a lot less resources but from a % standpoint they are both so low that their impact is effectively equivalent so I can compare them directly on ease-of-use, functionality, etc.

 

I get a ton more battery life on vim than I do on vscode and the JetBrains ides. Even when I load up vim with a ton of plugins. Sublime is also better than vscode, so thats a consideration if you like to work and not carry a brick with you. I do agree that for the most part the majority of us with modern computers the ram/cpu is a wash.

That is a much stronger point. To me this factor is still a wash because a) 95% of my development is done on a power cord and b) even if I'm out-and-about on my laptop what kills my battery is other intensive programs (aka FireFox) or running the program I'm working on rather than the editor itself. But I totally get that there are people who need to get more than a few hours out of their laptop at a time and will adjust their tools accordingly.

 

I'm diehard Vim all the way. I think it has the best UX of any editor.

I don't think Vim is an IDE though, and I do think that VScode is a good IDE. In fact, it has one of the best Vim-mode extensions of any IDE I've tried, so it's pretty fun to use. It's not perfect, the Vim-ness isn't that customisable, and it loses out because it's not a console application which is something I value.

 

You should try out the NeoVim extension if you haven't yet, it's quite a bit better than the normal one.

 

Looks interesting. I've always avoided neovim, but I think I might give this a shufty.

 

Linux is my IDE.

In all seriousness, it is. Most IDEs have a way of navigating to web pages, editing text, running commands, attaching debuggers...

You know what Linux lets me do?

Navigate to web pages, edit text, run command, and attach debuggers. And I can configure it exactly how I want it.

But what's even better? Parts of my IDE are available everywhere in the world - even Vim, my usual text editor. But I can also edit text with emacs or nano or ed(browse) or... whatever.

It's definitely worth learning a tool like VSCode, but if you want to avoid vendor lock-in, Linux is the way to go.

 

Also, if you do use something like Visual Studio or VS Code, I highly recommend a macro that will launch a proper editor like vim. Yeah, you can edit code in VS, but I really only find it's useful for composing code. You can edit code much, much, faster in Vim when you're doing anything but the most trivial actions.

 

With modern LSP plugins + fuzzy finders, I feel that I get the best combination with NeoVim, and I can edit code in Docker containers + Servers with IDE-like functionality. My dotfiles bootstrap NeoVim and install everything I need, so taking over a container to debug it is relatively painless :D

 

Would you like to share your dotfiles? I'm trying to set up multiple environments but kinda stuck...

 
 

I've gone hog-wild for VS Code, but I've used vi(m) since the 1990s and it's still in my fingers.

The primary reason I would use vi over code these days is when I'm editing code on a remote host I haven't mounted, which I sometimes do from my mobile devices, although as a Perl guy, perltidy uses perl, which I don't have installed in Windows, so, when I want formatted code (and I'm not using Remote-WSL), I use vi in WSL to tidy it.

 

I prefer to use Vim. It is really lightweight for my old computer.

https://dev-to-uploads.s3.amazonaws.com/i/dbvayc6c2joi74llq4mu.jpeg

 

Both are really good. I have ventured across all three lands including emacs, vim and vscode. The amount of time we can kill optimizing the configuration with vim and emacs is just 🤯 (both in a good and bad sense at the same time). Now while I get older, I realized that I don't have the time to tweak stuff until wee hours in the night. Having to manage time between work, family and my self. So these days , what ever gets me productive soon is my tool of choice. I might use vim to edit files and have a basic configuration that work out of the box. VSCode for majority of the other work purely because I work across PHP, Typescript, JavaScript, Ruby, Go and with Terraform. It just saves the time I have to configure the editor.

So this is just my circumstances and how I opt to use the little time I have available. It was a completely different ball game a decade ago for me.

 

I didn’t find VSCode to be that great without a similar amouint of configuration.

 

Possible. But most of the extensions work pretty fine out of the box.

 

I have been irritated by the sluggishness of electron apps for a while, and while vscode is the best electron app there is, it's still electron. I finally made the switch to vim and I love it. It will take while to get used to the key bindings but I'm willing to put in the work. And man configuring vim is so much fun!

 
 

VSCode has the best 'install and go' DX I've ever experienced. Even better than sublime, n++ - it just installs, starts, and goes really quickly with intellisense for TS/JS out of the box, and installing extensions is suggested and can be done without even reloading the editor.

 

It doesn’t have to be an either or. I’m quite happy using the vim plugins that are available in most IDEs, VSCode has a great vim plugin which does a good job of supporting the broad set of features I use (I guess I’m not a power user of vim).

I would be curious to see the difference in productivity between vim / emacs and plain IDE (with intelisense etc) at what point does vim make a difference?

 
 

I love vim on xfce. I have a workspace for every function key, 12 in all. Then, I use window snapping and when I am working locally i typically fill out all the 4 corners. Whew, that's a lot of windows but it really helps my workflow especially when each of them is tagged for certain purposes. I try to keep 1 set of function keys tied to a single project. Then on f1 I will have db windows, command line stdout app running, etc. Utility screens. f2 is reserved for website previews and debugging on the server. f3 is backend files and f4 is front end files. Bigger projects I'll go into a second set of functions and then the purpose gets more muddy.

Ultimately this has been fantastic and it is so speedy. All these are opened on a virtual machine and if it ever runs out of memory it isn't because of vim! Amazing!

 

I am all in for VSCode. I was a Jerbrains guy and started using vscode since 2018 and loving it. I am a Polyglot, and VSCode works and supports all programming languages I use. Nowadays, I use IntelliJ ( only Java ) and VSCode ( rest ).

 

Always been a touch-typist and started using text editors before VIM existed (those old Suns, NeXTs, etc., if they offered you a choice at all, only really had ed/vi and EMACS). Too many decades of finger-memory (and bounce too frequently across new systems) to think about stuff that isn't "just there". These days, that's VIM.

 

I recently switched from heavy IDEs and vscode to vim an I have found that can do everything inellij or vscode can do if the correct extensions. if your willing to put in the time to learn the key bindings and install the extension I think vim is by far the better choice. :]

 

I never could get into Vim's workflow. I know the hotkeys, but I guess my mindset just wasn't right for it. My university had both Vim and Emacs, so I got into Emacs and used it for a few years. But now, when I remote into any of my servers, I end up using Nano. Lightweight, and doesn't get in your way.

Once VSCode came out, that sealed the deal. Other than Visual Studio, I haven't found anything that equals its power, or flexibility.

 

I started using Vim 6 years ago, and spent 2 quality years with it. I had a heavily modded config with tons of plugins for everything. At some point, I wanted to do my own customisations, and VimScript didn't strike me as an amazing language (at least back in the day).

Then I went from Spacemacs to Doom Emacs, and I'm currently switching between Doom Emacs on Linux and VS Code on Windows.

Emacs gave me the degree of freedom I wanted from my editor, and for some of the plugins (like Magit <3), I can't find a replacement anywhere.

For me, VS Code wins in terms of LSP support (rust-analyzer works amazingly well with it) and how easy it is to get going with on a new machine (yay Preferences Sync!), but there's still a lot to be desired.

And of course, Vim bindings everywhere, that's out of the question.

 

I love VIM and saved my computers but when IDEs would chew up resources. But, I also love VSCode for the number of extensions, features, and constant improvements.
But in the end... Why not both? I used VSCode with the VIM extension so I can have keyboard shortcuts to fly around my code with the need for a mouse.
I do admit I don't use VIM to its full potential but I feel like it's not an all or nothing thing.

 

I never used VIM as a full-blown editor. Back when I started using Linux I would use it to modify config and text files or write shell scripts. Back in those days, I was only learning programming at a very basic level (I was young). I would use the Python IDE when I first started learning because I used Python. When I tried to learn C++ I was able to use Code::Blocks, which was relatively new at the time. I abandoned programming after that.

By the time I started development again, it was already 2016. I started with learning game development using Unity. This came bundled with MonoDevelop which I enjoyed using for a month or two before an online tutorial used Visual Studio and I switched. When I took up web development a few years after that, I just naturally fell into VSCode. I'm so used to all of the shortcuts and the commands that come wrapped in VSCode and that I have created. The idea of switching to anything else is almost exhausting.