Skip to content

hikyae/indentree.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

indentree.vim

Convert whitespace-indented structure into tree with box-drawing characters like tree command

demo

Installation

git clone https://github.com/hikyae/indentree.vim ~/.vim/bundle/indentree.vim
Plugin 'hikyae/indentree.vim'
NeoBundle 'hikyae/indentree.vim'
Plug 'hikyae/indentree.vim'
git clone https://github.com/hikyae/indentree.vim.git ~/.vim/pack/plugins/start/indentree.vim

Settings

You can set mappings and variables in your .vimrc file

  • Keymap for converting selected text in visual mode
vmap <Leader>I <Plug>(indentree-convert)
vmap <Leader>R <Plug>(indentree-revert)
  • Styles for tree structure
let g:indentree_style = 'unix' " default. like `tree` in Unix
let g:indentree_style = 'unix_ascii' " like `tree --charset=ascii` in Unix
let g:indentree_style = 'dos' " like `tree` in MS-DOS
let g:indentree_style = 'dos_ascii' " like `tree /A` in MS-DOS
  • You can also custom tree characters by defining g:indentree_styles in your .vimrc file
" example
let g:indentree_style = 'custom'
let g:indentree_styles = {
      \ 'unix':       ['    ', '', '└── ', '├── '],
      \ 'unix_ascii': ['    ', '|   ', '`-- ', '|-- '],
      \ 'dos':        ['    ', '', '└───', '├───'],
      \ 'dos_ascii':  ['    ', '|   ', '\---', '+---'],
      \ 'custom':     ['  ', '| ', '`-', '|-']
      \ }

Usage

Represent the directory structure with whitespace-based indentation.

This plugin uses 'tabstop' option to determine the depth of each node.

Though you can set expandtab, make sure to represent the structure using spaces with 'tabstop' width.

  • Command line
" convert all text in the buffer
:IndentreeConvert
" convert text within a specified range
:5,15IndentreeConvert
" revert all text in the buffer
:IndentreeRevert
" revert text within a specified range
:5,15IndentreeRevert
" switch to unix-like style
:IndentreeStyle unix
" switch to unix-like style with ascii option
:IndentreeStyle unix_ascii
" switch to dos-like style
:IndentreeStyle dos
" switch to dos-like style with ascii option
:IndentreeStyle dos_ascii
  • Keymap

Select text in visual mode and type the mapped key

About

Convert whitespace-indented structure into tree with box-drawing characters like tree command

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published