Skip to content

How to install nvim-ufo in LazyVim to enable foldable code blocks

Erica Pisani
Erica Pisani
1 min read
How to install nvim-ufo in LazyVim to enable foldable code blocks

A feature that I've found myself missing since making the switch to Vim as my editor of choice is the ability to easily fold and expand code blocks.

I know this functionality is included in Neovim, but I couldn't understand the native implementation enough to use it effectively and started searching for any plugins that gave me this ability.

I'm not the only one who's had this struggle (example Reddit thread here), and lots of folks point to nvim-ufo as the best plugin for this.

For those looking for a quick copy/paste configuration (LazyVim edition):

return {
  "kevinhwang91/nvim-ufo",
  dependencies = {
    { "kevinhwang91/promise-async" },
  },
}

Once you've reloaded your Vim config, try entering zc and zo within a function, code block, etc. to close and open a single fold in your code to confirm everything is working.

I haven't found that I've needed the other configuration mentioned in the 'minimal configuration' section of the project's README besides the keymappings and options such as foldlevel, foldlevelstart, etc.

tips-and-tricksvim

Comments


Related Posts

Members Public

Git Log's Hidden Gems: Using -S and -L for Powerful Code History Search

Ever needed to track down when a specific piece of code was first introduced in a project? As part of some refactoring I had to do recently, I needed to do just that for a variable on a Django model. I was already familiar with the basic git log command,

Git Log's Hidden Gems: Using -S and -L for Powerful Code History Search
Members Public

Using XOR to write concise conditionals

It's not uncommon that I sometimes write if statements where the overall conditional is true when both conditions are true or both are false. As an example, let's say I'm validating input from an API call where I'm updating information on a

Members Public

Fixing "No preset version installed for command poetry"

Poetry is a packaging and dependency management tool for Python, and a tool that didn't exist when I worked with Python many years before I started working at Float. I also hadn't been exposed to asdf, which is a handy little tool for managing multiple runtimes.