DEV Community

Discussion on: I'm switching to vim!

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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
siddharthshyniben profile image
Siddharth

Thanks for the tip!

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!