[{"data":1,"prerenderedAt":502},["ShallowReactive",2],{"\u002Fblogs\u002Fvim-vs-neovim":3},{"title":4,"description":5,"coverImage":6,"timestamps":9,"body":11},"Vim or Neovim? Here is Why You Should Use the Latter!","Discover why Neovim excels over Vim! Faster, cleaner, and loaded with features like LSP and Lua scripting. Enjoy seamless transition for Vim users, faster performance with Lua, and user-friendly defaults. Neovim: the modern, minimalist text editor",{"url":7,"alt":8},"https:\u002F\u002Fik.imagekit.io\u002Fjarmos\u002Fvim-vs-neovim.png?updatedAt=1702974992298","Vim vs Neovim: Which to Use?",{"publishedOn":10},"2021-07-15T00:00:00+00:00",{"type":12,"value":13,"toc":491},"minimark",[14,38,41,44,59,67,70,75,78,85,88,116,119,122,149,152,155,158,162,165,168,175,184,191,194,197,200,207,211,223,226,233,236,239,248,251,254,258,265,271,293,299,328,334,385,402,405,409,412,415,422,425,429,436,453,456,459,473,476],[15,16,17,18,25,26,31,32,37],"p",{},"If you ever heard of ",[19,20,24],"a",{"href":21,"rel":22},"https:\u002F\u002Fwww.vim.org",[23],"nofollow","Vim"," before, you would know all about\nit’s forks that have popped up in recent years! There’s\n",[19,27,30],{"href":28,"rel":29},"https:\u002F\u002Fneovim.io",[23],"Neovim"," (the most popular fork),\n",[19,33,36],{"href":34,"rel":35},"https:\u002F\u002Fgithub.com\u002FChristianChiarulli\u002FLunarVim",[23],"LunarVim"," (one of the most\npromising fork) & countless others. And as is obvious, choosing the one right\none for yourself can be a difficult task (been there & done that).",[15,39,40],{},"So to help you decide, this article will shed light on some of the reasons to\nchoose Neovim over Vim. To be more specific, we’ll look into every day use cases\nwhile comparing the two. Analysing everyday use cases is more relevant while\ncomparing consumer products anyway.",[15,42,43],{},"But before we dive into the real deal of the article, as usual a little bit of a\nhistory lesson first.",[15,45,46,47,52,53,58],{},"Vim itself started out as an improved clone of the now antiquated\n",[19,48,51],{"href":49,"rel":50},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FVi",[23],"Vi"," by\n",[19,54,57],{"href":55,"rel":56},"https:\u002F\u002Fmoolenaar.net\u002F",[23],"Bram Moolenaar"," way back in the early 90s. Moolenaar\nhimself overlooked the development & course of actions for Vim. Over the\ndecades, the Vim source code is starting to become archaic & hard to maintain.\nIt’s bloated, some of the code is unoptimized & it’s current set of features\nhasn’t aged well either.",[15,60,61,62,66],{},"But, Neovim was rebuilt from scratch! Redundant & decades old code was weeded\nout. And all the while the maintainers tried to provide the same power to the\nusers as Vim did. Although, it did come pre-packaged with “ ",[63,64,65],"em",{},"optional steroids","\n“ to consume. More on it in the rest of the article!",[15,68,69],{},"With that said, let’s dive deeper & check out why you should use Neovim over Vim\ntoday. Take due note though, this article isn’t intended as a jibe at Vim or\nit’s loyal users. Rather we’ll try to analyse the differing features of the two\neditors & see how useful they are on a day-to-day basis.",[71,72,74],"h3",{"id":73},"why-is-neovim-more-popular-thanvim","Why is Neovim More Popular Than Vim",[15,76,77],{},"As mentioned earlier Vim is pretty old, as such it’s source code is archaic &\ndifficult to maintain. And this was a primary reason for the current dev team\nfor Neovim to fork Vim & set off on a journey of their own.",[15,79,80,81,84],{},"Unlike some of the rumours floating around Neovim wasn’t forked because “ ",[63,82,83],{},"Bram\nis a dictator"," “ & what not. Neither was Neovim created to give more power to\nthe community. But the latter is definitely an unintentional outcome of the fork\nin a good way.",[15,86,87],{},"Since, Neovim was rebuilt from the ground-up, it opened up doors to;",[89,90,91,107,110,113],"ol",{},[92,93,94,95,100,101,106],"li",{},"Adding useful features like\n",[19,96,99],{"href":97,"rel":98},"https:\u002F\u002Fmicrosoft.github.io\u002Flanguage-server-protocol\u002F",[23],"Language-Server Protocol","\n(LSP), an embedded\n",[19,102,105],{"href":103,"rel":104},"https:\u002F\u002Fjarmos.netlify.app\u002Fposts\u002Fvim-vs-neovim\u002Flua.org",[23],"Lua 5.1"," (and\nLuaJIT) runtime & so on, more easily.",[92,108,109],{},"Cleaner & optimized source code for easier maintainability & reduced load\ntimes.",[92,111,112],{},"Straight-up better plugin development environment.",[92,114,115],{},"Extending core Neovim capabilities through improved plugins if necessary.",[15,117,118],{},"And those were only a few good outcomes of forking the Vim source code. But in\nreality, the list is never-ending & chances are, as Neovim matures over time,\nthere’ll be another reason to extend the list.",[15,120,121],{},"Some other equally prominent features include:",[89,123,124,127,130,142],{},[92,125,126],{},"The underlying Neovim API for plugin devs to use for building pretty much\nanything.",[92,128,129],{},"The optional embedded Lua 5.1 environment is also a reason why Neovim is so\nloved by the community. If a user wishes to do, Neovim can be configured\nwith Lua rather than VimScript.",[92,131,132,133,137,138,141],{},"An inbuilt standard library which includes useful functions like\n",[134,135,136],"code",{},"CheckHealth"," and\u002For the global ",[134,139,140],{},"vim"," Object. These are used to check if a\nplugin has been set up correctly. Or to configure global Neovim settings.",[92,143,144,145,148],{},"Comes pre-packaged with sensible default settings making the “",[63,146,147],{},"Vim\nexperience","” more pleasant.",[15,150,151],{},"And if it’s not obvious already, Neovim is already miles ahead when it comes to\nuseful features. For example, choosing to configure Neovim with either VimScript\nor Lua. Or heck if you desire, you can even use both side-by-side, the choice is\nall yours!",[15,153,154],{},"With Vim, you would be stuck with the dreaded VimScript! While LSP capabilities\nare supported through plugins, the experience isn’t as smooth & out-of-the-box\nlike it’s cousin.",[15,156,157],{},"With that said, let’s take a more detailed approach to some of the most used\nfeatures mentioned above.",[71,159,161],{"id":160},"neovim-is-noticeably-faster-thanvim","Neovim is Noticeably FASTER Than Vim",[15,163,164],{},"As mentioned earlier, one of the major reasons to fork Vim was it’s archaic\nsource code. Since Vim has been in existence for close to three decades it’s\nsource code is pretty bloated by now. It was hard to maintain & was much easier\nto simply rebuild from scratch, so the devs did what was necessary.",[15,166,167],{},"Owing to that decision, the source code was cleaned & optimized. This is obvious\nif you notice how faster Neovim is than its predecessor.",[15,169,170,171,174],{},"Rebuilding Neovim also opened up many doors towards developing handy features.\nOne & the most killer feature of the editor is the embedded Lua 5.1 ( ",[63,172,173],{},"and\nLuaJIT",") environment.",[15,176,177,178,183],{},"The devs also took other performance optimization course of action as well. One\nof them included making Neovim run in an\n",[19,179,182],{"href":180,"rel":181},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FEvent_loop",[23],"Event Loop",". So, you can finally bid\ngoodbye to plugins that would hang earlier!",[15,185,186,187,190],{},"Besides that, the devs have also ensured backwards compatibility with VimScript.\nSo, if you’re a long-term Vim user who wants to try out Neovim, don’t fret,\nyou’ll be fine. You can configure Neovim to read your older ",[134,188,189],{},".vimrc"," just fine\nalbeit with some trivial hacks here & there.",[15,192,193],{},"But what if you’re committed to using Neovim & are ready to take the dive? Then\nI would suggest migrating your current VimScript configurations to Lua code\ninstead. You’ll notice an increased performance boost.",[15,195,196],{},"To give an idea of what sorts of performance boost I’m talking about here, I’ll\nshare my experience. My Neovim load times decreased from 500+ ms to 237 ms.\nThat’s a roughly ~50% improvement by simply migrating from VimScript to Lua!",[15,198,199],{},"One can only imagine how much faster it can perform if the config loading\nprocess was optimized even further.",[15,201,202,203,206],{},"On the flip side though, configuring through Lua is an optional feature. So, you\nneedn’t feel obligated to “ ",[63,204,205],{},"learn yet another language"," “. More on it in the\nnext section of the article.",[71,208,210],{"id":209},"option-to-ditch-vimscript-embracelua","Option to Ditch VimScript & Embrace Lua",[15,212,213,218,219,222],{},[19,214,217],{"href":215,"rel":216},"http:\u002F\u002Fneovim.io\u002Fcharter\u002F",[23],"One of the goals"," of the Neovim team is to “\n",[63,220,221],{},"develop first-class Lua\u002FLuaJIT scripting alternative to VimL"," “. Staying true\nto their words, the devs haven’t enforced ditching VimScript in favour of Lua.\nAnd I doubt any of us would live to see that happen in our lifetime!",[15,224,225],{},"So, if you want to continue using your previous Vim configs, you needn’t fret at\nall. But what if you definitely need Lua code, for example say configuring the\nbuiltin LSP?",[15,227,228,229,232],{},"For situations like that, Vim ",[134,230,231],{},"heredoc"," will be at your rescue. You can embed\nLua code within VimScript with a syntax which looks something like this;",[15,234,235],{},"Example Lua code embedded within VimScript in the “init.vim” file",[15,237,238],{},"And you’re good to go out on your day without worrying it would break something\nfrom your previous Vim configs. Vim would still know how to parse those code &\nmake sense of it.",[15,240,241,242,247],{},"Although, a bit of a personal opinion here, try not to use VimScript if you can.\nCoding in Lua is a much pleasant experience. And even if you had to learn it,\nthe language has many real-life applications outside of a Vim environment. So,\nit’s not like you would be wasting your time learning a redundant programming\nlanguage. If you do decide to start configuring Neovim with Lua, do give this “\n",[19,243,246],{"href":244,"rel":245},"https:\u002F\u002Fgithub.com\u002Fnanotee\u002Fnvim-lua-guide",[23],"Guide to Using Neovim with Lua"," “ a\nthorough read.",[15,249,250],{},"That said, Neovim’s embedded Lua environment’s usefulness takes proper shape\nthrough it’s inbuilt standard library & API. If you’re either a plugin developer\nor a regular Vim user, the standard library can be useful in many ways. It\npackages many useful functions & commands to use for your day-to-day development\nneeds.",[15,252,253],{},"So, in the next section, we’ll take a more detailed look into it.",[71,255,257],{"id":256},"the-inbuilt-standard-library-the-api-is","The Inbuilt Standard Library & the API is 💖",[15,259,260,261,264],{},"Second on Neovim’s list of development goals is to create a suitable environment\nof plugin authors. That way, the plugin authors could extend the core features\nof Neovim with much ease. And the core team of devs achieved this feat by\ncreating the Neovim API layer & an accompanying “ ",[63,262,263],{},"standard library"," “.",[15,266,267,268,270],{},"The underlying API layer exposes useful functions to the user for programmatic\ncontrol over Neovim. These functions are exposed through a global namespace\ncalled ",[134,269,140],{},".",[15,272,273,274,277,278,281,282,285,286,285,289,292],{},"As such, let’s say we want to configure Neovim to display the number column.\nThen it’s as easy as writing ",[134,275,276],{},"vim.api.nvim_set_option(\"number\", true)"," in an\n",[134,279,280],{},"init.lua"," ( ",[63,283,284],{},"or"," ",[134,287,288],{},"*init.vim*",[63,290,291],{},"with some caveats",") file. And you're good to go!",[15,294,295,296,298],{},"Granted, a first glance on the global ",[134,297,140],{}," namespace might look confusing but\nstay with me & I'll help you make sense of it.",[15,300,301,302,304,305,308,309,312,313,316,317,320,323,324,270],{},"The ",[134,303,140],{}," namespace exposes a couple functions for everyday use. Most notable\nones include the ",[134,306,307],{},"vim.api",", ",[134,310,311],{},"vim.lsp"," & ",[134,314,315],{},"vim.inspect"," functions. There are a\ncouple more of them & explaining all them is out-of-scope for this article. But,\nyou can find a comprehensive list of these functions detailed in the \"",[134,318,319],{},"*vim*",[63,321,322],{},"namespace section","\" of the\n",[19,325,327],{"href":244,"rel":326},[23],"Lua for Neovim guide",[15,329,330,331,333],{},"To stay relevant to the context of this article, following are some of the most\nuseful functions exposed by the ",[134,332,307],{}," namespace:",[89,335,336,355,374],{},[92,337,338,339,342,343,346,347,350,351,354],{},"Functions for setting options like ",[134,340,341],{},"vim.api.nvim_set_option()",". Or the\n",[134,344,345],{},"vim.api.nvim_get_option()"," for getting the value of a global option. On\nsimilar lines, there are functions for Buffer-local and\u002For Window-local\nfunctions. These functions look like ",[134,348,349],{},"vim.api.nvim_buf_set_option()"," &\n",[134,352,353],{},"vim.api.nvim_win_set_option()"," respectively.",[92,356,357,358,361,362,365,366,369,370,373],{},"The “ ",[63,359,360],{},"Vim experience","” is pretty much incomplete without customizing\npersonalized key bindings. And , there’s a pretty nifty function for doing\nexactly that as well! The ",[134,363,364],{},"vim.api.nvim_set_keymap()"," function takes four\nparameters. The \" ",[63,367,368],{},"mode","\", your custom key binds, the expression\u002Fdefault key\nbinds & options ( ",[63,371,372],{},"like \"silent\"",") to pass to it.",[92,375,376,377,380,381,384],{},"Another function I found useful on a day-to-day basis is the\n",[134,378,379],{},"vim.api.replace_termcodes()",". It's used for escaping terminal & Vim\nkeycodes. Since VimScript does it by default, you never have to worry about\nescaping stuff like ",[134,382,383],{},"\"\\\u003CC-n>\""," times. But this doesn't work as expected when\nconfiguring through Lua code. Hence, this function can be pretty handy at\ntimes.",[15,386,387,388,390,391,394,395,398,399,401],{},"There’re many more of such functions & we barely scratched the surface of what’s\npossible! For more information on the ",[134,389,140],{}," namespace, refer to the \" ",[63,392,393],{},"Lua for\nNeovim guide","\" mentioned above. The official documentation at ",[134,396,397],{},"h: api"," is also\nquite handy for finding more info on the functions, the ",[134,400,307],{}," namespace\nexposes.",[15,403,404],{},"With all that power in your hands, the sky’s pretty much the limit to extending\nNeovim further than it’s core features. So, go figure it out yourself & don’t\nhesitate sharing them with the Neo(Vim)community.",[71,406,408],{"id":407},"sensible-default-settings-for-a-better-first-time-experience","Sensible Default Settings for a Better First-Time Experience",[15,410,411],{},"If programmatic configurations of your editor don’t sound interesting to you. Or\nperhaps, you tried out Vim some time earlier & found it difficult to use? Or\nmaybe you didn’t want to spend a whole weekend trying to configure Vim for your\nspecific needs? Well for you, my friend, there’s good news. Reducing the\nbarrier-to-entry for first-time Vim users topped the development goals for the\nNeovim devs.",[15,413,414],{},"So, what does it mean for the uninitiated?",[15,416,417,418,421],{},"It means, Neovim, out-of-the-box looks & feels good enough. It doesn’t need much\nof any configuration & it’s usable for all your software development needs.\nGranted this feature isn’t as interesting as Neovim’s other “ ",[63,419,420],{},"killer features","\n“ like inbuilt LSP. Or it’s programmatic config system through the embedded Lua\nenvironment. But it’s still an important feature worth noting.",[15,423,424],{},"When you want an editor that serves your purpose, helps you complete every-day\ntasks, you wouldn’t want to spend a day (or two) configuring it, wouldn’t you?\nAnd if you’re someone who fall into this category of people, Neovim is worth a\ntry. Who knows, you might like it & stick with it for the rest of your dev\ncareer.",[71,426,428],{"id":427},"final-words-resources-for-your-journey-into-neovim-land","Final Words & Resources for Your Journey into Neovim-land",[15,430,431,432,435],{},"And now, before I answer the question, “ ",[63,433,434],{},"Vim or Neovim: Which one to use?"," “.\nHere’s a short summary of everything we talked about earlier:",[89,437,438,441,444,447],{},[92,439,440],{},"Why does Neovim exist in the first place? And how it affected the community.",[92,442,443],{},"We now know, Neovim’s source code was cleaned, optimized & rewritten from\nscratch. Hence, it’s noticeably faster than it’s older cousin Vim.",[92,445,446],{},"Allowing Neovim to be rewritten opened up opportunities to include many\nuseful features like LSP, asynchronous execution, etc.",[92,448,449,450,452],{},"Inclusion of a “ ",[63,451,263],{}," “ which augments the optional embedded\nLua environment for configurability. Sensible default configurations to ease\na first-time Vim user’s experience.",[15,454,455],{},"…and many more! The list is never-ending & what I listed up there is just the\ncherry on top of the cake. These features are also what makes Neovim stand out\nwhen compared to Vim. But, it shouldn’t come as a surprise if Vim supports most\nif not all of Neovim’s features one day as well.",[15,457,458],{},"That said, you should use Neovim for reasons mentioned below:",[89,460,461,464,467,470],{},[92,462,463],{},"You need a terminal-based editor with stable cross-platform availability.",[92,465,466],{},"You’ve been a long-time Vim user & find certain features of the editor like\nVimScript annoying & frustrating.",[92,468,469],{},"You need modern IDE-like features like LSP support out-of-the-box and\u002For if\nyou need some default configurations available without further tinkering.",[92,471,472],{},"And finally, if you need a minimalist text editor which is modern, Neovim\nshould be your go-to option.",[15,474,475],{},"Do you believe those were some valid reasons to try out Neovim, let me know what\nyou think!",[15,477,478,481,488],{},[63,479,480],{},"Originally published at",[19,482,485],{"href":483,"rel":484},"https:\u002F\u002Fjarmos.netlify.app\u002Fposts\u002Fvim-vs-neovim\u002F",[23],[63,486,487],{},"https:\u002F\u002Fjarmos.netlify.app",[63,489,490],{},"on July 15, 2021.",{"title":492,"searchDepth":493,"depth":493,"links":494},"",2,[495,497,498,499,500,501],{"id":73,"depth":496,"text":74},3,{"id":160,"depth":496,"text":161},{"id":209,"depth":496,"text":210},{"id":256,"depth":496,"text":257},{"id":407,"depth":496,"text":408},{"id":427,"depth":496,"text":428},1789041548062]