Hacker News new | comments | show | ask | jobs | submit login
Turning vim into an IDE through vim plugins (safaribooksonline.com)
129 points by sds111 on Nov 6, 2017 | hide | past | web | favorite | 62 comments

While I would never sell it as "turning vim into an IDE", I use most of these plugins. ctrl-P is great, but I would probably switch to fzf if I was bothering to update my vimrc and plugins lately.

Fundamentally, I think people trying to sell emacs/vim with plugins as "turn X into an IDE" are sort of not getting what people see and get from IDEs, though. There's quite a bit more integration that goes into IDEs and what you're making is a pretty barebones/poor IDE with these plugins.

Most languages, though, don't need an actual IDE for them to be great. You need the auto-completion, automatic compilation/error checking, jump to definition, easy-to-reach documentation, etc., for them to instantly be super productive while coding.

Spacemacs with Haskell plugins is one of the best coding experiences I've had and it even taught me some patterns that I didn't know about. Another highlight is OCaml tooling that works really great with both Emacs and vim.

I don’t disagree on principle, but a highly-configured Emacs can easily reach levels of integration that I think is worthy of the “Integrated Development Environment” label. For vim, I suspect it’s more like “as close to IDE level as a dedicated vim user is likely to want”. (Fwiw, I use Emacs a lot, vim a little, and my hardcore IDE usage is several years back, so maybe that’s just my biases showing.)

> a highly-configured Emacs can easily reach levels of integration that I think is worthy of the “Integrated Development Environment” label

I disagree. I've _never_ seen an integration into emacs that comes close to a _good_ integrated debugging experience. Similarly, the navigation/refactoring integrations tend to feel bolted on, rather than integrated. (you're using projectile and irony mode? They both have different representations of what your "project" is, so you have to keep both up to date). Again, actually "building" from emacs is something I've never seen done well. You've inevitably got the compile command which you have to write yourself, but my IDE can parse its own project file, generate a list of targets and configurations (predefined compiler flags for optimisation/definitions) and build those in one keystroke. I've also never seen any integration of any autocomplete that works with configurations either.

I'm a longtime Emacs user, and I think you're generally right. But Emacs Lisp, SLIME, and CIDER are exceptions to these observations.

And what exactly is it that you're getting from an IDE?

You get refactoring, jump to def, auto completion, linting, code snippets, documentation, depending on the languages you use. For Java there are more lightweight alternatives which lack refactoring features that IntelliJ has, but there has been eclim for ages. But that's using eclipse in the background you say? Well, at some point you're bound to use a language native component to use reflection.

What about Omnisharp? How was Monosharp an IDE and vim with Omnisharp integration, which was based on the same components wasn't?

I feel like the discussion has degraded to peoples perceptions of what an IDE should be. And for most people that perception is: "It should look like IntelliJ" or "It should look like Visual Studio".

Maybe what you really mean is:

It should have refactoring.

It should have auto completion.

It should do performance instrumentation.

It should allow debugger integration.

And then there's the question of how far each feature has to be integrated. For most IDEs performance instrumentation is really just a seperate tool that you can launch form the IDEs toolbar.

debugger integration ... performance instrumentation ... really just a separate tool that you can launch from the IDEs toolbar.

Which is actually awfully close in usability terms to <hotkey to next terminal> + <full featured shell> # just sayin'

Sorry, but I really don't understand this. What of these can you not get in emacs?

> There's quite a bit more integration that goes into IDEs and what you're making is a pretty barebones/poor IDE with these plugins.

I think even that's putting it generously. It's not turning vim into an IDE at all, just adding some modern text editor features like you'd find in Atom or Sublime.

I find that proper IDE (intellij for example) is way better for statically typed languages, not so much for dynamic ones

Having seen this article when I first started using vim seriously, I'd recommend fzf.vim in place of ctrl-p and ALE in place of Syntastic. The former I find is much more performant, and the latter takes advantage of Vim8 / neovim's asynchronous features. Plus, fzf.vim comes with Ag, which effectively replaces Ack.vim (albeit, with a little bit of tweaking).

The article also recommends neocomplcache, whose github says its deprecated and to use neocomplete, which is also deprecated and suggests you use deoplete. At least the chain ends there for now.

FZF is fantastic, but has anyone managed to make it work in MacVim? I just get weird display corruption and control characters in my search string when I use it.

Works great in the terminal and neovim.app etc.

You can go even further by using FZF+ripgrep, it's so much faster.

I think you can get better results with ctrlp when using cpsm as its matcher. fzf.vim always starts at the top and cpsm actually minds your current file.

That is the reason I chose neomake, because syntastic was dragging vim down. I'm curious, how does ALE compare to neomake?

Using ALE right now. By design: Syntastic runs synchronously on save, Neomake runs asynchronously on save, ALE runs asynchronously as you type. Neomake is good but I see no reason to go back from ALE which works brilliantly.

Neomake can do that too: https://github.com/neomake/neomake#setup

I tried very hard to get used to Vim. I just feel compared to something like Visual Studio Code it's still very clunky.

I can understand why people who have used it for a decade prefer Vim over other text editors. They already know how to use it and how to integrate it into their workflow. For a newcomer this task, it seems, is nigh insurmountable.

Are there people who recently got into it and think it's the superior way to code and why?

For me, it was a lot of wasted time trying to learn Vim and finding out that other editors that I already use are as good or better.

> I tried very hard to get used to Vim. I just feel compared to something like Visual Studio Code it's still very clunky.

This just means you failed to get used to Vim. Has nothing to do with it being "clunky".

I use Vim for many cases, and other IDEs for when I'm forced to use them, such as Android studio (IntelliJ) for Android, XCode for iOS, and certain languages where it's hard to remember the syntax, so I think I'm qualified to answer, coming from a user of all of these editors.

For dealing with API-heavy frameworks I think IDE is good. But even then I prefer to have some sort of Vim plugin integrated into the editor so I can take advantage of shortcuts from both the IDE itself and the Vim scheme.

One benefit with Vim is that it's become almost a standard that you can find vim plugin in any IDE (Except for recent changes in XCode) so you can just expect to jump on to any editor and be immediately productive, without having to learn each editor command. You don't have that for Sublime or Atom. Sure some editors have similar commands for dealing with similar features, but not always.

It's an "editing scheme", not just a single editor.

This is why it's much more efficient in the grand scheme of things than any other editors exactly because of that, in my opinion.

Editors will come and go, but editing schemes are forever.

> Are there people who recently got into it and think it's the superior way to code and why?

I started coding with Visual Studio, and then later Eclipse. I like both IDEs. I only learned about vi/vim about a year after I started programming, and it looked intimidating.

2 years after that, I decided, fuck it, let's see if I can do this. It took me one day to learn how to comfortably navigate with the hjkl keys, as well as how to copy/paste and save/exit. Which was all I needed at first. Over the next two weeks I learned a few more things that you could do, and I never looked back.

It wasn't difficult at all to learn vim. The only thing that I can think of that would make it difficult to learn, is if you don't know how to touch type.

As for why I think it is superior:

The . (repeat) action is so insanely useful and saves you so much time.

Most actions are blazingly fast compared to a gui text editor. e.g. To delete a whole line just press dd instead of home + shift + end + delete

Memorizing all these shortcuts is easy, becuase they are based on a 'grammar' that makes new command combinaitons easy to guess.

There hasn't been one feature that and IDE has that I used, which can't be achieved in vim (or via a plugin)

vim doesn't take up crazy resources, and is installed on most systems by default anyway. And the startup time is almost instant.

Funny thing, learning programming (and in particular, learning vim) taught me touch typing.

I was a 80WPM hunt-n-peck typist, and my typing/"business computing" teacher in High School was a 25WPM touch typist. She couldn't convince me it was worth learning, so I never did. I'd fake it and other bs until we finally moved on after about 2-3 months.

However, after programming for about 3 years, I realised that I had subconciously learned how to touch type, and with about a month of concentrating on better finger usage, I achieved a more "proper" touch typing form.

My one complaint about vim: muscle memory. After using vim for years, you'll find random :w's and :q's at the end of so many emails or documents in other programs!

> Most actions are blazingly fast compared to a gui text editor. e.g. To delete a whole line just press dd instead of home + shift + end + delete

Ctrl + X works on most 'gui text editors'

> There hasn't been one feature that and IDE has that I used, which can't be achieved in vim (or via a plugin)

How does "find references" work in vim? If i want to find all usages of a method called "getName", does it know how to differentiate between calls on an object of the class I'm searching from, or usages from all classes that have a "getName" method (aka dumb text search)?

Depends on the language. For C/C++ there is rtags, which compiles your code with clang and extracts type info, after which it can find all usages of said method on the exact class you're searching for. I personally use ctags and rtags together for code browsing, to alleviate problems one or the other has. Rtags can be a bit unstable and slow-ish, while ctags is just for definitions and somewhat of a dumb text search.

So far every C/C++ IDE I've seen on Linux has been incredibly dodgy, unstable, resource-hungry, etc. The text editor compoment is invariably light years behind vim and the actual "integrated" parts are of similar quality, so I continue using vim with enough plugins to get the job done. That doesn't really give you an IDE, it gives you a coding component of a Non-integrated Development Environment, where you build and test on the commandline by running commands and scripts, commit by running git, etc. I'm honestly perfectly fine with an NDE, as long as each component does its job reasonably well. I've tried various gdb integrations and they're so horrible, I just learned how to use vanilla gdb on the console. So yes, setting a breakpoint means copying the method name from vim and pasting it in gdb's commandline, but the important part is that it works and keeps working and doesn't set the breakpoint wrong, or crash, or put my editor in some weird state, or lose connection with the debugger (literally how??), etc. So I just use ol' reliable tools to get the job done without fuss.

About the only one that I've seen that actually works is QtCreator, but its license costs more than VisualStudio's, and it's definitely not worth the price (to me or my employer). CLion I've also heard good things about, but couldn't put through its paces enough before the trial period ran out.

I think we can all agree that all C++ editors are a complete disaster. The language is too hard to parse and process, noone ever managed to make good tools.

Visual studio and Qt Creator are the least worst IDE. The first one only works on Windows obviously. They are both free so I am not sure why you'd mention pricing issues???

Visual Studio has the best debugger by far, I'd go as far as saying it's the only debugger in existence for C++. If you have money, there is a paid refactoring plugin called Visual Assist X that makes the C++ experience a lot better.

JetBrains also released ReSharper C++ which is better than Visual Assist X in my experience.

KDevelop, Netbeans and Eclipse CDT are also quite good.

> Ctrl + X works on most 'gui text editors'

Really? Even if you haven't selected the line? Because if you haven't selected the line then you'll have to use your mouse first or do the home + shift + end + Ctrl + X to delete the line.

I remember Ctrl + D does this (without needing to select the line) in Eclipse. But it's still faster to type dd than Ctrl + D

> How does "find references" work in vim?


> Really? Even if you haven't selected the line?

Absolutely, works for the entire line, no matter where you are.

> But it's still faster to type dd than Ctrl + D

Don't be overly pedantic. I could say Ctrl + D is faster because dd means: 'press d' + 'release d' + 'press d' while Ctrl + d means 'press Ctrl' + 'press d', or I could say that you don't have to change modes to use Ctrl + D, but you could say your finger is already on d, you're more comfortable, etc. The difference in speed is quite negligible.

> https://stackoverflow.com/a/9616315

Using cscopes sure is better than dumb text search, but apparently doesn't know the difference I asked about. From the comments:

> Now that I've spent a bit of time with cscope, it seems to me that cscope does not differentiate variables of the same name that belong to different classes. class_b::var may be returned even though I'm only looking for class_a::var. I'm using C++. Am I doing anything wrong?

Maybe it works better for other languages. However, my point is: if you think "There hasn't been one feature that and IDE has that I used, which can't be achieved in vim (or via a plugin)", then I don't think you've used JetBrains IDEs.

> Really? Even if you haven't selected the line?


Ctrl + D is delete the line on some editors, duplicate the line on some editors. Prepare to be surprised when trying to to use it across environments.

Ctrl + X is the shortcut for cut (as in cut then paste). It cuts the current selection. It doesn't auto select the line if there is no selection.

Every editor is different, including vim. In Sublime Text 3, it's Shift+Delete to delete a line, and whether it goes to your clipboard or not depends on a config setting. There's a shortcut to duplicate a line too, but I don't remember the default because I've customized it.

Well, if you want to be really pedantic:

Ctrl + Y is delete without copy (at least in IntelliJ IDEA).

Have you found a plug-in that handlea autocompletion/find references/go to definition as well as SlickEdit or Eclipse?

I tried ctags and a few others for autocompletion, etc. They were super complicated to install and use. Also they do not find references properly, having a bunch of misses or false positives.

I like Vi style editing, but I found it better to use a real IDE and find a Vi plug-in for it.

There are a whole bunch of plugins for autocompletion (depends on the language you are using)

Find references : try [0] or [1]

go to definition (I haven't searched for this functionality, so I don't know if it exists)

[0] https://github.com/asenac/vim-opengrok [1] https://stackoverflow.com/a/9616315

> go to definition (I haven't searched for this functionality, so I don't know if it exists)

It's a pretty fundamental code navigation feature. You said "There hasn't been one feature that and IDE has that I used, which can't be achieved in vim (or via a plugin)", but it seems you haven't used any significant IDE features. Have you tried refactors like "rename" (method, class, variable, field) or "extract method"? Have you tried searching for overriding methods? Have you tried inlining variables or extracting expressions to variables? Have you tried debugging? Evaluating expressions during debug is something you can do in Java and Eclipse [1] / IDEA [2].

Or, if you want something really impressive, how about Async stacktraces?[3] It shows all the frames for both the spawning thread and the spawned thread in the same stack during debug.

There are a lot of really cool features in IDEs like IntelliJ IDEA have which are impossible to achieve with plugins in VIM, simply because IDEA parses the code and works at AST level. Not only that, but there are hundreds of inspections, automatic fixes and refactors which work perfectly (or almost perfectly) on top of that AST.

[1] http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse....

[2] https://www.jetbrains.com/help/idea/evaluating-expressions.h...

[3] https://blog.jetbrains.com/idea/2017/10/intellij-idea-2017-3...

There's no question, that editors like vim or emacs have a very steep learning curve and it might not payoff for everyone.

I'm using vim now for ~15 years and it all started during university on a unix machine with a limited number of options, so I was somehow forced to learn either vi or emacs. I don't know if I would have ever learned vim if I had the options of today.

But I also like powerful tools, so perhaps I still would have, and what I like most about these more powerful editors is the ability to optimize them to my prefered workflow.

Sometimes you've to fiddle a bit around, which can be very annoying, but at the end I almost always get to a solution I like to work with.

> I just feel compared to something like Visual Studio Code it's still very clunky.

From my perspective, if you're trying to turn Vim into an IDE, you're using it in the wrong way. Vim is an excellent text editor and leave it at that. Whatever you still need (build system, file management, version management, package management, debugging, log collection, and so on), build your environment with external tools that have nothing to do with Vim.

What I found about Vim is that it requires a bit of mind shift, compared to other IDEs. I came to the game very late, but yeah, I've been editing with Vim for the past 6-7 years. My primary motivation when moving to Vim, was that I didn't like using mouse and then running back to the keyboard to write text. Now, it might not seem like much time is wasted during this shift, but imagine doing this many time during work day and it adds up. Furthermore, I did a lot of editing on remote systems, which were headless, so you didn't get graphical editors.

When learning Vim it's not wise to learn about everything at once. start slow at first, lear a few commands, then when you find you are doing something many times, try to find way to optimize it. Try not to use mouse for highlighting, use different visual modes instead (visual line, visual block are great).

Here is article be the Vim author which can give you some hints on how to edit files: http://moolenaar.net/habits.html

And as he mentions there, it can be applied to making your editing more efficient with other editors as well, so it's not a waste of time :)

I coded in vi for years using a vt100 terminal. I used emacs for a couple of years. Went back to vi when vim came out. I still use vi when I need to make a quick change from the command line. It is very useful when you log remotely. But I would hate to use vi for software development when we have IDEs, and modern programming editors like sublime.

Surprised they recommend a single colorscheme (jellybeans) at bottom of article.

Moving between machines and terminals different colorschemes seem to work better than others. This has like a million colorschemes (OK, slight exaggeration but it does have more than I've been able to review. Usually pick from 5 or 6 favorites commented out in .vimrc).


Also they recommend https://github.com/Shougo/neocomplcache.vim (which I've used for years). Reviewing some vim plugins the other day I noticed that github hasn't been updated in 3 years and recommends another plugin now. (Don't plan on switching until it breaks though).

Guessing this article may be a few years old?

<edit>Yes, it says 2014 at top

Might be good if the date could be mentioned in the title:-)

This is from [2014] and contains outdated information. Can someone update the headline?

As posted elsewhere, we now have vim 8, ALE instead of Syntastic, fzf/fzy instead of ctrl-p, and more.

That article seems somewhat out of date now.

For a more up to date approach I'd suggest Drew Neil's Modern Vim book (still in beta)[1] and using async language server plugins[2]

[1] https://pragprog.com/book/modvim/modern-vim

[2] https://langserver.org/

"NERDTree satisfies this need of mine, replacing vim’s built-in netrw file navigator with a nicer-looking, less buggy, more fully featured alternative."

Wait, what's wrong with the built-in netrw? I actually started with NERDTree before I knew netrw existed. After discovering netrw, I switched to it instead. I think it looks just fine and prefer it to the more complex NERDTree.

I agree, it's better to work with the internal tools if possible. I did install Tim Pope's vinegar plugin [0] as it adds some nice tweaks to netrw.

But I've since switched to using FZF [1] and hardly use netrw anymore.

[0]: https://github.com/tpope/vim-vinegar [1]: https://github.com/junegunn/fzf/blob/master/README.md#as-vim...

Cool, thanks for the recommendations. I've tried ctrlp for fuzzy finding, and it works ok. Might give FZF a try though.

I'm surprised the author didn't mention vim's sessions feature. The ability to close the editor/IDE and pick up right where you left off can save a lot of time when working with multiple large projects. It's easy enough to use on its own, but I have a small wrapper plugin that adds a few features for ease of use: https://github.com/bgrohman/vim-bg-sessions.

For which Tim Pope's Obsession plugin [0] is fantastic. It solved a whole bunch of weird conflicts that I had with plugins.

[0]: https://github.com/tpope/vim-obsession

Cool, I haven't used that one. I'm sure it's great coming from Tim Pope. Mine's working fine for me at the moment, though.

Good list! Also, if you work with databases (particularly PostgreSQL) and want to work with them from Vim, check out dbext: http://jonathansacramento.com/posts/20160122-improve-postgre...

Link to dbext here: https://github.com/vim-scripts/dbext.vim

I'll add one more suggestion:


"A Vim plugin which shows a git diff in the gutter (sign column) and stages/undoes hunks."

Thats a cool plugin but I had performance problems with it once a file gets above about 1k lines of code so I had to uninstall it :(

I recommend vim-workspace for IDE-like tabs. Helped me a lot in working with Vim buffers.


I'll be honest, the only time I try to tweak my VIM setup to be close to an IDE is when I have no other options (developing on a remote box). It's always a pretty frustrating experience IMO.

Why not just use an IDE if that's what you need with a Vim mode plugin rather than shoe horning Vim into something it is not really meant to be. Virtually every major IDE has a Vim mode.

Speaking for myself:

* Vim mode in IDEs often only implement the most basic vim commands

* I'm able to work remotely over a slow/spotty connection

* I really hate waiting 10-30 seconds for my editor to start. Often I want to peek at code, then change my mind and want to edit it. I can remotely login and start my editor in less time than most IDEs take to load.

* I like dropping to my shell (not just a shell)

Who says what vim is meant to be? A lot of example vim setups I see are too much for me (too much to set up, too fickle to maintain, too slow in practice)...many of those apply to IDEs for me. But it's nice to see what's out there and how other people fit the pieces together.

I use IntelliJ with IdeaVim at work and I can vouch for it, but the truth is that even the better plugins for the more mainstream IDEs suffer from strange and annoying issues. For example:

will not actually surround a word in parens (without a space at the edges) and then move down and do the same to the word on the line below. Surround commands cannot be repeated in IdeaVim. It's about as good a try as I've seen at emulating vim outside of Emacs, but it's certainly not complete at all.

What you said about shoehorning vim into being an IDE can be said about shoehorning IDEs into being decent editors. It's extremely hard to get both and depending on the language it's better to get the IDE with so-so editing or get the stellar editing with most of the productivity boons of nice integration.

There'll always be a part of me that wants to learn vim better and set something like this up. Then there's the other part of me, that just uses Sublime instead.

Most of these plugins make Vim more like ST. Having switched from ST to Vim I have spent lots of time trying to add in the bits I miss.

But there are benefits of Vim that ST are ever likely to have fully:

* Open Source

* Editing inside ssh

* The programmable way of editing which you'll never teach yourself if you don't dive in. I can't even quantify if this is better, but it feels better and you only need a few percent improvement over your editing/refactoring speed to be worth it over the years

* fully custom, you set it up exactly the way you want it. I never felt tempted to create shortcuts in ST, but it's much more standard in Vim

* it's good to understand Vim's way of editing even if you go back to other editors

* in theory you can pretty much do everything that ST can do in Vim but I don't think you'll get the full power of Vim if you try to recreate it in ST

The learning curve is steep but learning Vim is worth it.

Subjectively I think it's worth it because vim feels more comfortable to me but I'd be surprised if Textmate/Sublime/Atom are any less productive. They're all pretty good editors.

This should be only an experiment at best. Please don't waste so much time trying to turn a tool into something that it is explicitely not.

If you just want an IDE experience use one that already exists. If you want to build your own out of plugins, use something like Emacs that has something like that as a core feature.

If you really want to learn vim though, then please learn the IDE that it is already integrated in: Linux. Linux based OSes are the most extensive IDEs because in the past nobody thought there would be a difference between a programmer and a computer user. So it's the most complete system that you can find. And additionally to solving all your programmer problems you also learn an OS and its components on the way.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact