--------------------------
| |
| |
| headings.vim | <- The quickest way to do this
| |
| |
--------------------------
Important! This plugin depends on NERDCommenter
- Add
Plug '414owen/vim-headings'
to your vimrc file. - Reload your vimrc or restart
- Run
:PlugInstall
Vundle or similar
- Add
Plugin '414owen/vim-headings'
to your vimrc file. - Reload your vimrc or restart
- Run
:BundleInstall
- Add
NeoBundle '414owen/vim-headings'
to your vimrc file. - Reload your vimrc or restart
- Run
:NeoUpdate
cd ~/.vim/bundle
git clone https://github.com/414owen/vim-headings.git
(For Neovim, change ~/.vim/
to ~/.config/nvim/
.)
curl -fLo ~/.vim/plugin/headings.vim --create-dirs \
https://raw.githubusercontent.com/414owen/vim-headings/master/plugin/headings.vim
curl -fLo ~/.vim/doc/headings.txt --create-dirs \
https://raw.githubusercontent.com/414owen/vim-headings/master/doc/headings.txt
headings.vim defines two functions: Heading(size)
and UnHeading(size)
. You
can use them with call
, for example:
:call Heading(3)
and
:call UnHeading(3)
No mappings are defined by default, but mappings are highly recommended. Here
are mine:
nmap <leader>h1 :call Heading(1)<CR>
nmap <leader>h2 :call Heading(2)<CR>
nmap <leader>h3 :call Heading(3)<CR>
nmap <leader>h4 :call Heading(4)<CR>
nmap <leader>h5 :call Heading(5)<CR>
nmap <leader>h6 :call Heading(6)<CR>
nmap <leader>h7 :call Heading(7)<CR>
nmap <leader>h8 :call Heading(8)<CR>
nmap <leader>h9 :call Heading(9)<CR>
nmap <leader>dh1 :call UnHeading(1)<CR>
nmap <leader>dh2 :call UnHeading(2)<CR>
nmap <leader>dh3 :call UnHeading(3)<CR>
nmap <leader>dh4 :call UnHeading(4)<CR>
nmap <leader>dh5 :call UnHeading(5)<CR>
nmap <leader>dh6 :call UnHeading(6)<CR>
nmap <leader>dh7 :call UnHeading(7)<CR>
nmap <leader>dh8 :call UnHeading(8)<CR>
nmap <leader>dh9 :call UnHeading(9)<CR>
I can then hover over a line of text and press \h2
, \h4
etc. to turn it
into a heading, and \dh2
, \dh4
etc. to delete an existing heading.