DEV Community

Cover image for I'm switching to vim!
Siddharth
Siddharth

Posted on • Edited on

I'm switching to vim!

UPDATE: There are a lot of Vim tips in the comments. Check them out!

I just took a short look at the (neo)vim docs, and I'm officially moving to (neo)vim (and tmux)! I have just used it for a few days, but I really can feel the power it gives me. Not to mention that it really saves my 6GB ram for other uses.

A snapshot of my coding session

And I encourage all of you to do the same. It really is super faster (I come from vscode, and it is really faster). Vim has everything you need – Syntax highlighting, Split screen, File explorers(!), Autocomplete(!), Tabs, Folding lines(!), Indentation autofixing(!), macros, line bookmarks, integrated terminal like interface and what not (I should make an article on it soon). Vim is basically equivalent to VSCode for me.

Top comments (140)

Collapse
 
turutupa profile image
Turutupa • Edited

It's great that you changed to vim, seems very exciting! It would be cool if you could explain the process on how you changed to vim. Personally I use VSCode with vim extension for keyboard shortcuts. And I think it would be really cool to move fully to vim, but it's hard... first problem is file navigation. VSCode makes it so easy to open up files using ctrl/command + p. There might be some other stuff that I'd miss from VSCode when moving to vim but file navigation is my road blocker I guess.

How did you overcome that?

Collapse
 
siddharthshyniben profile image
Siddharth

The process how I switched to vim? I don't get it. I just installed vim and started using it. No plugins installed yet

About file navigation, there is a builtin file explorer. Just cd to the parent folder, open vim, and run the :Explore command (I guess you know what the :commands)

You get something like this:

Image

Collapse
 
turutupa profile image
Turutupa

That actually answered my doubts. So no plugins for file navigation, explorer & buffers as well I suppose. Thanks!

Thread Thread
 
siddharthshyniben profile image
Siddharth

You rarely need plugins. Most of the stuff is built in.

Thread Thread
 
mafflerbach profile image
mafflerbach

But there are plugins for vim as well.
Eg. for filenavigation (with a tree is nerdtree) but netrw (:Explorer) has as well a tree view ( cycling with i between the views)

For fuzzy search over files vim-fzf, i think it handles the open buffers as well, but if not - there is defnitly a plugin for it somewhere....

Thread Thread
 
siddharthshyniben profile image
Siddharth

Yeah there are a lot of plugins.

I'm having some trouble installing plugins, especially because I'm using neovim which is a bit different.

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

vim-plug should be roughly the same on neovim and vim. Been using it for several years, can recommend.

Thread Thread
 
siddharthshyniben profile image
Siddharth

Hmm, but I'm having trouble installing it on my outdated machine

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

What is the error you're getting?

Thread Thread
 
siddharthshyniben profile image
Siddharth

Fixed it now, used vim-plug instead of vundle

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

Nice work, all the best.

Collapse
 
vinodnimbalkar profile image
Vinod Nimbalkar

If you are planning to use neovim version 0.5+ then try github.com/nvim-telescope/telescop..., Its cool.😎

Thread Thread
 
siddharthshyniben profile image
Siddharth

I don't think I'll have such deep filesystems... I might try it once i get back to angular

Thread Thread
 
turutupa profile image
Turutupa

wow, that is a cool plugin

Thread Thread
 
ludamillion profile image
Luke Inglis

It's an absolute beast. And I mean that in the best way. Pairing that with NeoVim 0.5+'s built in LSP features and you have a lot of VSCode's ground covered.

Collapse
 
navhalarjun profile image
Arjun Navhal

It's rekated to putty

Collapse
 
brandonwallace profile image
brandon_wallace

Turutupa, You can use a popular plugin called NERDTree for file navigation. You can also use FZF. I have both installed because they work differently. NERDTree is good when you know where your file is. FZF is good when you know part of the file name.

Vim is highly configurable, I but you can get anything that works in VSCode to work in Vim. Check out this article:

Vimrc Configuration Guide - How to Customize Your Vim Code Editor with Mappings, Vimscript, Status Line, and More

freecodecamp.org/news/vimrc-config...

Collapse
 
turutupa profile image
Turutupa

By the comments I've seen so far and what I have seen lately related to vim file navigation, I think a good combination would be

  • fzf
  • nerdtree
  • harpoon

Gotta try it. Cheers for the help!

Collapse
 
siddharthshyniben profile image
Siddharth

Thanks for the tip!

Collapse
 
felixfong227 profile image
Felix Fong • Edited

👋 I have been using VSCode with Vim extensions for a good couple of years now, and I have been successfully and happily switch to full Vim(neo) for the pass 5+ months . And to my surprise that VSC and Vim can be quite similar with little to no config at all 🎉

And as for file navigation with ctl/cmd + p, there is a vim extension call Ctrlp github.com/kien/ctrlp.vim

Hope it helps 😄

Collapse
 
turutupa profile image
Turutupa

Nice, I'll check it out. I just feel like without a fast an easy way of switching between files it's a no go for me. This one seems like a good one though, thx for sharing :)

Thread Thread
 
ludamillion profile image
Luke Inglis

Something a lot of new Vim users don't know about is the c-^ mapping which allows you to jump back and forth between the two most recently visited buffers. Added bonus the most recent buffers are local to windows/splits.

Thread Thread
 
felixfong227 profile image
Felix Fong

I believe in VSC’ Vim it’s mapped to the ctl+i keybind🤔

Thread Thread
 
turutupa profile image
Turutupa

didn't know about c-^ ! that's a good one, thanks!

Collapse
 
sakethkowtha profile image
sakethk

There is plugin called Telescope u can try that. U will like it

github.com/nvim-telescope/telescop...

Thread Thread
 
moopet profile image
Ben Sinclair

That's only for neovim, though. Other plugins like vim-fzf will work on regular vim too and give you a lot of the same functionality.

Collapse
 
yoann9344 profile image
Yoann Guillard

The most underestimated vim's functionality that we should teach to beginners is vim session, allowing to save your session like any IDE !
stackoverflow.com/questions/164261...

Collapse
 
turutupa profile image
Turutupa

Hey Yoann, how do you use vim sessions? And I don't mean like what commands you use or anything like that. More like, how you use vim sessions in your workflow?

Thread Thread
 
yoann9344 profile image
Yoann Guillard

I just use it simply, I have quickly a lot of tabs opened, so when I have to change the project on which I'm working or when I shutdown then I save the session at the root of the project. But it could be interesting to save it automatically, once I screwed and killed the vim process and I lost a dozen of open tabs and the workflow that went with it ^^'

Rarely, I work on more than one functionality at the same time, then I use and save 2 sessions in the same project.

Collapse
 
klvenky profile image
Venkatesh KL • Edited

I've tried to convert to vim atleast thrice & had to falllback as I've different requirements compared to others (atleast I think so). I work with/modify multiple projects at a time as I work heavily on microservices built in an event driven system. So I really never have any memory of the function previously written nor the code.

I'll tell you what I expect from my editor (vscode now)
1) quick navigation(ctrl+p) - solved it using fzf/ctrl-p
2) quick search (ctrl+ shift+f) - hard to get around this
3) find function/variable by name(ctrl+t -> not that great but still does decent work. I'd prefer intellij's double shift, but it's an IDE so different story altogether) - didn't last till this point
4) easier to configure language support(vim-polyglot does well here but I'd like little less config)
5) sensible defaults(neovim does this I think)
6) easy navigation to error like from terminal
7) Goto definition - my biggest problem, I couldn't find something that'll work well for multiple languages. Coc.vim has some awesome support as per multiple articles but I couldn't find a single place to configure as it has a separate config file so it's a little tricky for me to manage.
8) find all references - I think vscode nails it. I know I could do a search/grep for text but I'd ideally have similar variables in same file as I do a lot of ETL/ELT.
9) simpler Emmet support - I did try installing the plug-in but could make it easy to go with.
10) snippet manager - I don't use snippets heavily but it's a nice to have feature

I'd love to know if there are better solutions for these issues which should make me switch to vim.

I did try using vscode vim but I work a lot in zenmode so search goes for a toss here as the activity bar gets hidden.

Collapse
 
turutupa profile image
Turutupa

Hey man, you got very valid points and I must admit I didn't realize how much stuff I needed till I tried moving from VSCode to vim. Fortunately a lot of people replied to my comment and I have learnt a lot of good stuff in the past week.

I cloned Lunarvim (neovim based) which comes packed with a bunch of plugins and it does cover a lot of the stuff you mentioned. I've seen there are other known configs such as Lvim and Gleipnir, but I can't say which one is better or the differences between one and another.

I'll respond to some of the points you mentioned in case it helps you out.

1 - this is nicely done with Telescope
2 - still learning how to do this, but to be honest I don't think I'll need it so much anymore as I can search for references with Lsp saga (i think that's the name) or I believe you can use built-in vim funcionality by pressing gd
Points 3,7 and 8 slightly similar to this
(link to lsp saga: github.com/glepnir/lspsaga.nvim )

4- language support is a pain in the ass, luckily lunarvim also covers it

I do enjoy a lot working with VSCode + vim plugin though and I 100% understand why you'd stick with VSCode.

Thanks for sharing your experience!

Thread Thread
 
klvenky profile image
Venkatesh KL

Thanks I'll checkout the resources mentioned. All the best to all

Collapse
 
yoann9344 profile image
Yoann Guillard • Edited

2/ is a simple git grep could make the job ?
3/6/7/8/ I think it depends on the quality of your LSP, I'm happy of Ale : bind AleGoToDefinition ; AleFindReference ; github.com/dense-analysis/ale#5xi-...
Then just configure your preferred LSP for each language you use.
9/ I never get bothered by Emmet, so I don't get your concern (except on vscode)
10/ I think ultisnippet is nice, I have to check my config

Thread Thread
 
klvenky profile image
Venkatesh KL

I will have to spend some time figuring that out then. I am not one of those super person's who become productive within a week. May be I need to figure it out.

I am not that great with color schemes & all so I would like some nice color scheme recommendations as well.

Thread Thread
 
siddharthshyniben profile image
Siddharth

There are a lot of built in ones. Try desert.

Thread Thread
 
klvenky profile image
Venkatesh KL

Sure I'll check it out. Thanks

Thread Thread
 
yoann9344 profile image
Yoann Guillard

I'm starting to remake and clean my full config, 'cause I would like to switch to nvim. So I can share my dot config, once it will be done.

Collapse
 
gosukiwi profile image
Federico Ramirez • Edited

There are lots of plugins you can use for finding files. The most popular right now is fzf, give it a shot, I'm sure it can beat your VSCode workflow in a few days of customization/learning :P

I personally use ctrlp + ripgrep

Collapse
 
turutupa profile image
Turutupa

oh man... I thought it would never be possible to fully move to vim... but someone shared me lunarvim (github.com/ChristianChiarulli/Luna...) which comes with telescope and it is a beast

Thread Thread
 
gosukiwi profile image
Federico Ramirez

Prebuilt configurations are great for getting started. Once you are used to it, maybe after a few years, consider trying to customize it and remove what you don't need/want. Read the documentation and learn if there's a way you can replace a plugin with just native Vim functionality. And eventually, try writing your own config from scratch. That's where Vim shines. But it's not an easy process ^^;

Thread Thread
 
turutupa profile image
Turutupa

Totally agree. Some people suggest to start from scratch your own config, but I feel like it has been a way better introduction to vim using pre-built configs than having to create one myself without understanding a thing. At least now I have a decent notion from the time I've spent setting up lunarvim + tweaking some stuff to accommodate to my needs.

Collapse
 
jdeepd profile image
JDeep • Edited

Checkout NerdTree plugin . I use a combination of fzf and nerdtree to navigate and its blazinglyfast compared to mouse switching. Combine all of them with a multiplex terminal like kitty or tmux, you are now a rocket.

Edit : Also, dont forget about vifm

Collapse
 
turutupa profile image
Turutupa

I see that combination working for me. What I don't fully see is what it has to offer that VSCode + vim extension already offers. I also have ctrl + p to open files fast in VSCode. Plus configuration is way easier in VSCode, for example, one thing I really like in VSCode is being able to set line height so code isn't so cramped together.

Another annoying one is syntax highlighting. Last time I used vim it wouldn't recognize React + Typescript (tsx), so then I have to spend a bunch of time just to be able to have that working :/

My feeling is to stay with VSCode and use vim for fast editing.

thanks for adding vifm, didn't know that one

Thread Thread
 
jdeepd profile image
JDeep

Ya , for a web developer, VS Code Vim is probably the best because the default Vim has some problems with formatting and indenting HTML and CSS. You can get it to work exactly as VSC but it will take a lot of time in configuring it. For me, I think I have invested a lot of time in configuring Neovim to my liking 😅 and plugins like Vim move , quick scope , vim wiki and doge keeps me hooked to it.

Thread Thread
 
turutupa profile image
Turutupa

mind sharing your config? :)

Thread Thread
 
jdeepd profile image
JDeep
Thread Thread
 
turutupa profile image
Turutupa

thanks man :D

Collapse
 
heyprotagonist profile image
Anguram Shanmugam

Watch DistroTube youtube he has a playlist on vim
or
Search for this book "Mastering Vim Quickly by Jovica Ilic"

Collapse
 
rebuilt profile image
rebuilt

Check out lunarvim. It's made specifically for users switching from vscode github.com/ChristianChiarulli/Luna...

Collapse
 
turutupa profile image
Turutupa

God. Fucking. Bless. You.

This is exactly what I have been looking for. Not so much cause it brings a similar exp to VSCode, cause it is vim, I don't expect to have the same experience. But because it is an easy out-of-the-box config. This is very important for me, cause whenever I change to a different machine I always try to keep my configs simple and easy to install. Same with tmux. I use oh-my-tmux instead of my own config so I can easily install it wherever I go. Obviously I could create my own configs, but it makes way more sense for me to use the already existing ones from people with way more experience.

Sorry for the long reply, long story short: this is awesome.

Perhaps a simpler config would have been sufficient, but I am definitely trying this out. Thanks again!

Collapse
 
kaushikrishi profile image
Kaushik Rishi

Hey, There is a vim plugin called ctrl.p that does the same job but much faster, also there is another package called fzf which does similar thing.

Collapse
 
siddharthshyniben profile image
Siddharth

fzf is a general purpose library to fuzzy find files. Many plugins use fzf under the hood

Collapse
 
yurenchen profile image
yurenchen • Edited

Image description

LunarVim is powerful, and out-of-box.
//for beginner: just press space call for popup-menu

BTW, is there any bookmark extensions?

Collapse
 
siddharthshyniben profile image
Siddharth

Check out marks :help mark-motions, they are builtin minimal bookmarks. I use a plugin which enhances marks: marks.nvim.

If you really want bookmarks, check out vim-bookmark. There are many others, and integrations too. A quick google search will help you find them.

Collapse
 
gchandran profile image
Hemachandran G

Each tool has its own set of ups and downs. In the case of Text Editors, Vim is good for code maintaining i.e, where you do more updations than writing something new. But, when we are building something from the scratch, we might need more third-party support and GUI intensive workflows, that's where using Vim is not a good idea.

Collapse
 
gnsp profile image
Ganesh Prasad • Edited

I have built a number of things from scratch, including but not limited to, a couple of compilers, an UI library in react, few websites end to end, few web services, a number of fun side projects; I have done a number of freelance projects during my time in college too. I have never needed anything more than a terminal (guake on my Linux machine and iterm2 on my work laptop) and a browser (chrome only. I use browserstack for testing/previewing on other browsers). Vim has been an integral part of my Dev setup. It may not have all features of a modern IDE, but it's best at what it does-- text editing. For all other features that I need in my workflow, there is always a CLI tool that specialises in that. Even though I have tried multiple IDEs over the years, I found that the only useful thing that comes out-of-box with IDEs is static code analysis. This is the only thing that doesn't come with vim out-of-box, you need plugins for that. Most of the useful text editing features in modern IDEs are present in vim or covered by some plugin. Also I found that autocompletion in other IDEs feel fancier, but it's generally faster to write code without autocompletion as long as you are a decent typist and know what you're doing; also if your class, method and variable names are so verbose that autocompletion is faster than typing them out, then it's an indication that you need to reconsider the way you're naming stuff.

Collapse
 
siddharthshyniben profile image
Siddharth

Woah, you've built a lot of stuff

Collapse
 
aghost7 profile image
Jonathan Boudreau

What would be an example for a GUI workflow?

Collapse
 
siddharthshyniben profile image
Siddharth

What do you mean?

Collapse
 
siddharthshyniben profile image
Siddharth

Yeah, vim really is made for editing. But really most developers spend more time editing than coding - at least I do

Collapse
 
val_baca profile image
Valentin Baca

"But really most developers spend more time editing than coding"

huh?

Thread Thread
 
gchandran profile image
Hemachandran G

It depends on the situation and the environment. Let's say you are a freelancer, most probably you'll be creating different new projects. If you are working in a Company, it's highly probable that you'll be maintaining the codebase.

My conclusion is to, use the right tool for right work.

Thread Thread
 
siddharthshyniben profile image
Siddharth

I mean we usually type out our code then spend a lot of time running it, and tweaking it and debugging it right?

At least it applies to me

Thread Thread
 
siddharthshyniben profile image
Siddharth

I mean we usually type out our code then spend a lot of time running it, and tweaking it and debugging it right?

At least it applies to me

Thread Thread
 
val_baca profile image
Valentin Baca

Thanks. I see: I just never saw "editing" as separate from "coding" or that "coding" only meant when it was written the first time.

To me it's just all coding and all editing.

Personally, I used to be a vim power user, and I'm still glad I learned it and still use it very often. However, as my primary editor, VS Code has really taken over for me.

Compared to vim, with VS Code I've never lost a file or even a single edit, I don't have to mess with swap or backup files.

But like others have said, they're tools. They're not religions. Pick the best for the situation and there's no harm in learning something new.

You can checkout my ~/.vimrc here: github.com/valbaca/dotfiles/blob/m...

And my "virc" which is a more minimal vimrc here: github.com/valbaca/dotfiles/blob/m...

Thread Thread
 
siddharthshyniben profile image
Siddharth

Yeah the swap file thing is real. It's happened to me a few times

Collapse
 
leob profile image
leob

Right ... VIM is great, but I don't believe in the current hype about switching away from VSCode to a bare bones editor - for the record, VSCode is an editor, it's pretty lightweight and a far cry from traditional heavy IDEs like Netbeans/Eclipse and so on ... VSCode for the win :)

Collapse
 
siddharthshyniben profile image
Siddharth

I don't too 😂. You don't have to switch if you have a good computer (not a 10 year old one like mine) which can handle VSCode or if you already use all of vscode features.

Thread Thread
 
leob profile image
leob • Edited

I think we agree then, mine is almost 10 years old as well but I've got 16 GB inside so why not just use that RAM ;)

Thread Thread
 
siddharthshyniben profile image
Siddharth

Mine is a 2010 MacBook which runs macOS 10.12 (I really need to upgrade). There is a computer which runs windows 10 here but I won't use it 😂

Thread Thread
 
leob profile image
leob

Windoze ;) no neither would I, haha

Collapse
 
mafflerbach profile image
mafflerbach • Edited

I see quite often in the comment "here you can use my dotfiels, vimrc etc" At this point i would recoment to take a peak in the conf, but not blindly use them, I dont linke spaceVim either. I ve added plugins, when i needed it, and not because they sound maybe usefull. If I noticed i use features often, but have to type much i create a mapping for it.
eg:

" ripgrep for the current word/WORD under cursor  
noremap <leader>a :Rg <C-r>=expand('<cword>') <CR>
noremap <leader>A :Rg <C-r>=expand('<CWORD>') <CR>

" yank in WORD into register a s or q
map <leader>1 "ayiW
map <leader>2 "syiW
map <leader>3 "qyiW

" using resgister a and s for search and replace
map <leader>rp :%s/<C-R>a/<C-R>s/g
Enter fullscreen mode Exit fullscreen mode

also strg+f in comand node is very helpfull, if you want to alter a command from the history or th ecurrent one.

You workflow has to develop and will change over the time as well you vimrc will. I compare the vimrc to underware. Its your underware, which fits to you, and you don't realy want, that somebody else shit in it.

Collapse
 
leob profile image
leob

Your mean your VSCode is using SIX GIGABYTES of memory? I don't know but I guess you might be doing something wrong ...

Anyway, while I'm also a fan of VIM and use it frequently besides VSCode, there's no way I'm going to do away with my VSCode just to save a few bytes of RAM - I think VSCode is well worth the memory it consumes ... and VIM is also great, they make a great pair.

Collapse
 
siddharthshyniben profile image
Siddharth • Edited

Nope VSCode is not using 6gb. I have a total of 6gb and vscode uses a huge chunk of it. Throw in Chrome and you have problems

Another thing is I don't really use all the features of vscode, so I really thought vim would be nice

Collapse
 
leob profile image
leob

Okay that makes sense ...

Collapse
 
brandonwallace profile image
brandon_wallace • Edited

If you consider the UI to be ugly add a color scheme. There are a ton of them available. One popular color scheme is called Molokai. This repository, all by itself, has 128 color schemes available!!

github.com/chriskempson/base16-vim...

Just copy all the *.vim color schemes into your ~/.vim/colors/ directory. Try the color schemes in Gvim and Vim to see how they look. Also you can add a custom font like Hack font or a font you have installed on your system .

Collapse
 
justintime4tea profile image
Justin Gross

Welcome to the fold!

I made the switch from VS Code a couple weeks ago ( took ~2-3 days to adjust) and am now at feature parody with the features I was using in VS Code.

For me it wasn't so much about optimizing resource consumption but rather having a portable easy and quickly reproducible dev env setup that I could connect to from anywhere. It is nice to save gigabytes of RAM though :)

I switch between computers a lot and had been using SSH Remote plugin to do all my work in a remote Linux setup. Combining TMUX persistent sessions, neovim and vim sessions means I can connect from anything/anywhere and it's all ready to rock and roll all the time! It even works well connecting to my dev env from an Android device using TERMUX! With a nice portable keyboard I could totally do all my work from a silly little Android tablet or Chromebook.

I started with the coc plugins but then quickly jumped to nightly neovim + native lsp. Primarily writing Rust applications but also have had great success with typescript and Vue/nuxt application development. If anyone is stuck getting something set up or has questions on how you might do something in neovim that you were previously doing in Code please ask me here and I'll share any feedback that I can!

Collapse
 
siddharthshyniben profile image
Siddharth

Thanks! I'll ask you if anything comes up.

Collapse
 
samuelabreu profile image
Samuel Abreu

I'm using neovim for almost 2 years now, and my advice is, don't try to replace one for another, chance is you get disappointed. Same for emacs.

Start using for small tasks (like quick edits or specific tasks like json files), and improve your config files as needed.

If you still have the urge to use more, research for plugins for specific needs, for development Coc is really good for beginners.

Collapse
 
siddharthshyniben profile image
Siddharth

I'm thinking of first writing the code in VSCode and then doing all other edits and debugging in vim

Collapse
 
elvisoric profile image
Elvis Oric • Edited

When using nvim, you can create terminal buffer with :terminal command

Collapse
 
mr_destructive profile image
Meet Rajesh Gor

save time, just

:term

will work ;)

Collapse
 
siddharthshyniben profile image
Siddharth

Nice tip!

Some comments may only be visible to logged-in visitors. Sign in to view all comments.