Skip to content

Blake-LeBlanc/vim-sort-folds

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SortFolds

Overview


(Demo \w SimpylFold, colorscheme xoria256)

Sorting folds is not easily possible in vanilla vim. You could join all lines in a fold, sort and split them up again; however, it is time consuming and tedious.

This little plugin solves that issue: It sorts a visually selected region while keeping closed folds intact. Since folds can be created in a variety of ways, it is therefore straight-forward to sort arbitrary groups of text based on their first line.

One use-case (demonstrated above and the original motivation for this plugin) is to sort functions alphabetically after the fact.

Furthermore, it is possible to sort based on a other lines than then first.

Installation

SortFolds is compatible with most plugin managers for vim. Just drop the following line in your .vimrc:

Plugin 'obreitwi/vim-sort-folds' (for Vundle)

Plug 'obreitwi/vim-sort-folds' (for vim-plug)

Mappings

Per default, sorting visually selected folds is mapped to <leader>sf, if available, but can be easily remapped.

Note: manual foldmethod

This plugin was not tested and is not expected to work with foldmethod set to manual for now.

Python 3

vim-sort-folds is now Python 3 compatible. The last Python 2 compatible commit is still available as tag last-py2.

About

Sort vim folds based on their first line

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 89.3%
  • Vim Script 10.7%