Code Folding in Neovim

  Рет қаралды 13,892

Andrew Courter

Andrew Courter

Күн бұрын

In this video I go over the different code folding methods in Neovim and how to configure my favorite plugin, nvim-ufo to make code folds even better.
KickstartNvim: github.com/nvim-lua/kickstart...
NVIM_APPNAME: neovim.io/doc/user/starting.h...
Code Folding Function: • Coding a foldcolumn To...
nvim-ufo: github.com/kevinhwang91/nvim-ufo
Companion Article: / code-folding-in-neovim
Join this channel to get access to perks:
www.youtube.com/@ascourter/join
Twitter: / exosyphon
Website: andrewcourter.com
Twitch: / exosyphon
Gear:
Mic: amzn.to/40GUGFg
Mic Interface: amzn.to/3YGxaGE
Mic preamp: amzn.to/3XtBXtY
Webcam: amzn.to/3OEOZRU
Boom Arm: amzn.to/3qLr0GE
Vissles (VS II switches): vissles.com/?ref=69zn8aei20 - Coupon Code for $5 off: ANDREWCOURTER
IQUNIX F97 (TTC ACE switches): iqunix.store/collections/f97-...
🎵 Music
Music: Evan King
/ @contextsensitive
contextsensitive.bandcamp.com/
⏰ Timestamps
0:00 Intro
0:30 Example
0:59 The Fold Methods
1:29 Manual
3:32 Indent
4:06 Marker
5:09 Syntax
5:39 Expr
6:38 Diff
7:14 Troubleshooting and saving folds
7:58 Custom keymaps
8:36 nvim-ufo
10:57 Outro
#neovim #coding #programming

Пікірлер: 63
@ascourter
@ascourter 7 ай бұрын
What code folding plugins or methods do you use?
@LinuxForLife
@LinuxForLife 2 ай бұрын
I am using AstroNvim which provide all of this out of the box. No configuration needed.
@ascourter
@ascourter 2 ай бұрын
@@LinuxForLife AstroNvim uses nvim-ufo so now you know how it is configured! :D github.com/AstroNvim/AstroNvim/blob/main/lua/astronvim/plugins/nvim-ufo.lua
@bassamsaleh8034
@bassamsaleh8034 7 ай бұрын
One of the best videos I've seen. I always had hard time with folds in neovim. Thanks a lot
@ascourter
@ascourter 7 ай бұрын
Thank you!
@JoshMedeski
@JoshMedeski 7 ай бұрын
Nice overview of how folds work. I learned some new things! And I’ve set some custom icons with UFO as virtual text to not clutter up the gutter.
@ascourter
@ascourter 7 ай бұрын
Thanks Josh! Oh nice. I think you mentioned this to me before, I'll check out your config again to give that a try!
@iusearchbtw4969
@iusearchbtw4969 7 ай бұрын
I didn't know i need folding before in neovim, now i need one cuz i need to read long php code from my senior and i came accross this video Anyway thank's for the amazing and simple explanation video without going through much of configuration
@rkbgkgmjfm5155
@rkbgkgmjfm5155 7 ай бұрын
Code folding is one of those things I never use, but cool to see you cover topics like these
@ascourter
@ascourter 7 ай бұрын
Thanks! Let me know if there are other topics you are interested in!
@thadrunsfaster
@thadrunsfaster Ай бұрын
Enjoying your content! Subscribed!
@ascourter
@ascourter Ай бұрын
Thank you!
@feresp
@feresp 7 ай бұрын
GREAT video man! Thanks!
@temelgunaydin7585
@temelgunaydin7585 3 ай бұрын
Indent method is good for now. Thanks for all information that you shared.👍
@legion_prex3650
@legion_prex3650 6 ай бұрын
nice stuff! keep on teaching!
@drewberchtolzthofen886
@drewberchtolzthofen886 2 ай бұрын
Pretty handy, thanks!!
@cantucodes
@cantucodes 7 ай бұрын
Great Video! I had no idea there were so many options! Agree that nvim-ufo is 🔥
@ascourter
@ascourter 7 ай бұрын
Thanks! Yeah there's a ton built-in
@cody_codes_youtube
@cody_codes_youtube 7 ай бұрын
Yeah buddy! Always love your content!
@ascourter
@ascourter 7 ай бұрын
Thanks Cody! Right back at you!
@kraigochieng6395
@kraigochieng6395 5 ай бұрын
be blessed.
@bihanbanerjee
@bihanbanerjee Ай бұрын
Thanks a lot man. ❤❤❤
@sumanth3036
@sumanth3036 7 ай бұрын
Awesome. Comprehensive
@ascourter
@ascourter 7 ай бұрын
Thank you!!
@arnoeagleeyes
@arnoeagleeyes 7 ай бұрын
Hey great video ! Do you happen to know if you can switch it off for certain buffers ? Like Dapui for example ?
@ascourter
@ascourter 7 ай бұрын
Thanks! You should be able to turn it off using UfoDisable (github.com/kevinhwang91/nvim-ufo#commands). You could then create a keymap to do it manually or run that in a ftype file for language types you didn't want it on.
@arnoeagleeyes
@arnoeagleeyes 7 ай бұрын
@@ascourter Thank you for your answer. For anyone interested. This is what i did in my dap.lua: dap.listeners.after.event_initialized["dapui_config"] = function() require("ufo").detach() dapui.open() end
@GrzegorzMilka
@GrzegorzMilka 7 ай бұрын
Does folding and unfolding by one level work with nvim-ufo? I don't any mentions of remapping zr/zm.
@ascourter
@ascourter 7 ай бұрын
Yes, folding one level should work out of the box with nvim-ufo. You need to remap zR and zM because it will override foldlevel if you don't. github.com/kevinhwang91/nvim-ufo#usage
@setobiralo
@setobiralo 7 ай бұрын
The video was really helpful. Thank you. Is there any way to save the fold state even after closing the buffer?
@ascourter
@ascourter 7 ай бұрын
Thanks! Good question. I believe you could save the folds to a file and reload them like I mentioned. You could set that up via auto command too
@setobiralo
@setobiralo 7 ай бұрын
Thank you for your answer. I managed to do it just like you mentioned.
@mokied
@mokied 2 ай бұрын
Hey thanks, for the video. I had a hard time setting up ufo & understanding how it should be used. I still have an issue with fold not remaining persistent after quitting nvim. What did I miss?
@ascourter
@ascourter 2 ай бұрын
Checkout this link to add a couple autocommands to save the folds. github.com/kevinhwang91/nvim-ufo/issues/115#issuecomment-1436059023
@fegyi001
@fegyi001 7 ай бұрын
very helpful video, thanks a lot! Just one question - rather irrelevant to this video, sorry for that -, but I really like how your terminal looks with showing the git branch icon and the nodejs version as well. How can one do that?
@ascourter
@ascourter 7 ай бұрын
Thanks! Haha good question. I use starship as my prompt. Here's how I configure it: github.com/exosyphon/dotfiles/blob/main/starship.toml
@fegyi001
@fegyi001 7 ай бұрын
@@ascourterwow, thanks a lot!
@alopradocai
@alopradocai 6 ай бұрын
Nice video. I gave up on using folding because every time I would use a formatter, folds would always get disorganized.
@ascourter
@ascourter 6 ай бұрын
Thanks! Yeah I've heard that from a couple folks. I've seen suggestions about workarounds but sometimes I think how the formatter is implemented just messes folds up.
@alopradocai
@alopradocai 6 ай бұрын
@@ascourter Who knows, maybe there is a good way of both working together. Right now I prefer using just the formatter and no folds.
@GonzaloStoll
@GonzaloStoll Ай бұрын
@alopradocai which formatter do you use? Supposedly conform doesn’t mess with your folds. Been using it for months and it works jim-dandy
@alopradocai
@alopradocai Ай бұрын
​@@GonzaloStoll I use mostly intelephense for php and typescript-language-server for js, also have php-cs-fixer. I need to review/study a lot about nvim, because my config is a little too messy, folds might take a while for me to revisit, but thanks for the tip appreciate it.
@rkdeshdeepak4131
@rkdeshdeepak4131 7 ай бұрын
How to enable folds for particular filetype e.g. norg, markdown?
@ascourter
@ascourter 7 ай бұрын
Check out this link to the docs. You get a filetype in the provider_selector where you can map the provider and provide an empty string for filetypes you don't want to have folds on. github.com/kevinhwang91/nvim-ufo#customize-configuration
@Ace10thPlanetJJ
@Ace10thPlanetJJ 23 күн бұрын
Ive installed ufo and its dependency in kickstart, and lazy tells me it installed correctly, but whenever i type "require('ufo')" anywhere and restart the editor i get an error that the ufo module cant be found, i cant find any info on how to resolve this anywhere
@ascourter
@ascourter 20 күн бұрын
You might open an issue on the nvim ufo github page. See if they might be able to get you sorted. You can double check the plugin is getting installed under ~/.local/share/nvim/lazy
@aumhren3480
@aumhren3480 24 күн бұрын
with foldmethod=indent, how to fold all code (ie all class ...) indents at once ? thx for sharing, have fun
@ascourter
@ascourter 24 күн бұрын
Thanks for watching! I believe you can use zM to close all folds. Give that a try and let me know if that does not work for you.
@Faisal_89
@Faisal_89 4 ай бұрын
Andew , How can we select or copy whole function and can we jump function to function?! Love your content brother
@ascourter
@ascourter 4 ай бұрын
Thank you! What language are you programming in? It kind of depends on the language for selecting but vap or va{ might do the trick. Check out this other video about jumping around buffers if you haven't already: kzbin.info/www/bejne/fXvRoGOilNN0r8k I also will do another type of video like this before long.
@Faisal_89
@Faisal_89 4 ай бұрын
@@ascourter thanks, checked the video , learned many things.currently I am working with js/ts. we can do it with symbols. but if there any short key way select whole function please tell me. like i want to copy whole function or delete it.
@Faisal_89
@Faisal_89 4 ай бұрын
@@ascourter thanks brother ,va{Vd works well. and exactly vaf / daf to select or delete whole function
@mokied
@mokied 2 ай бұрын
You need to set up Text Objects You can use nvim-treesitter-textobjects for that
@naranyala_dev
@naranyala_dev 7 ай бұрын
A small trick, but it can still improve workflow
@innerthreatcircus5651
@innerthreatcircus5651 2 ай бұрын
Any trick to have color picker to edit css? Thankssss
@ascourter
@ascourter 2 ай бұрын
Do you mean having a color picker for RGB values in CSS?
@innerthreatcircus5651
@innerthreatcircus5651 2 ай бұрын
@@ascourter yeah, but I found exactly that, a color picker. And already installed it. Thanks a lot
@ascourter
@ascourter 2 ай бұрын
@@innerthreatcircus5651 Nice! What plugin did you end up installing?
@innerthreatcircus5651
@innerthreatcircus5651 2 ай бұрын
@@ascourter color-highlighter and color-picker
@kubectlgetpo
@kubectlgetpo 2 ай бұрын
So we went from simple code folding in vscode to a 15 min video and it still doesn't work well
@ascourter
@ascourter 2 ай бұрын
Code folding in Vim is pretty complex for sure. Nvim-ufo gives you a lot of great stuff.
@kubectlgetpo
@kubectlgetpo 2 ай бұрын
@ascourter yeah I am loving neovim so far but also missing some of these modern features. It's a fair compromise so far TBH. I am ok letting go off folding in lieu of faster jumping across the screen.
Configure vim-surround in Vim & IntelliJ
5:56
Andrew Courter
Рет қаралды 2,6 М.
Making Tmux Better AND Beautiful -- here’s how
10:56
typecraft
Рет қаралды 59 М.
small vs big hoop #tiktok
00:12
Анастасия Тарасова
Рет қаралды 13 МЛН
Final muy increíble 😱
00:46
Juan De Dios Pantoja 2
Рет қаралды 26 МЛН
Automatically Execute *Anything* in Nvim
11:03
TJ DeVries
Рет қаралды 67 М.
Null-ls IS BEING ARCHIVED | Prime Reacts
32:02
ThePrimeTime
Рет қаралды 90 М.
I'm never using Git the same way again
11:19
typecraft
Рет қаралды 82 М.
Ultimate Quickfix List Guide
10:15
Andrew Courter
Рет қаралды 17 М.
My Neovim & Tmux Terminal Dev Workflow As A Principal Engineer
9:22
DevOps Toolbox
Рет қаралды 36 М.
Tmux has forever changed the way I write code.
13:30
Dreams of Code
Рет қаралды 914 М.
Vim Folds Make Your Code More Readable
9:45
NeuralNine
Рет қаралды 4 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 175 М.
These HIDDEN MOTIONS in Neovim will CHANGE how you work
11:11
DevOps Toolbox
Рет қаралды 21 М.
сюрприз
1:00
Capex0
Рет қаралды 1,6 МЛН
Ждёшь обновление IOS 18? #ios #ios18 #айоэс #apple #iphone #айфон
0:57
APPLE совершила РЕВОЛЮЦИЮ!
0:39
ÉЖИ АКСЁНОВ
Рет қаралды 2,9 МЛН