mirror of
https://github.com/ZNielsen/nvim-blockformatter.git
synced 2026-06-19 00:11:08 -06:00
A small block formatting plugin for Neovim
- Lua 91.2%
- Vim Script 7.8%
- Makefile 1%
| .github/images | ||
| doc | ||
| lua/blockformatter | ||
| plugin | ||
| .gitignore | ||
| include.mk | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
nvim-blockformatter
A small block formatting plugin for Neovim
| Command | Description |
|---|---|
BlockFormatterNormalize <arg> |
Formats a block of text to wrap at the specified column. |
BlockFormatterNormalizeRange <arg> |
Formats a visual range of text to wrap at the specified column. |
BlockFormatterComment |
Toggles a leading comment for the line. May take a leading count argument. |
BlockFormatterCommentRange |
Toggles a leading comment for a visual range. |
BlockFormatterAlign |
Format trailing content to be in the same column. Takes leading count arg. |
BlockFormatterAlignRange |
Format trailing content to be in the same column. Uses visual range. |
BlockFormatterAlignAuto |
Format trailing content to be in the same column. See helpfile. |
To use, just Plug 'ZNielsen/nvim-blockformatter' or similar. Mappings are recommended, as the command names are a bit verbose. Suggestions are below.
The minimap in the examples is minimap.vim.
Examples
Block Normalization
Example Maps
nnoremap <leader>bn100 :<C-U>silent lua require("blockformatter.block_normalize").normalize_block_normal(vim.v.count1, 100)<CR>
nnoremap <leader>bn80 :<C-U>silent lua require("blockformatter.block_normalize").normalize_block_normal(vim.v.count1, 80)<CR>
vnoremap <leader>bn100 :<C-U>silent lua require("blockformatter.block_normalize").normalize_block_visual(100)<CR>
vnoremap <leader>bn80 :<C-U>silent lua require("blockformatter.block_normalize").normalize_block_visual(80)<CR>
Block Commenting
Settings
g:prefer_wrapping_comments(default 0) - For filetypes that support both line comments and wrapping comments, set to true to prefer wrap-style comments- Example: C has
//and/* */. Set to0(default) would yield// <line>. Set to1would yield/* <line> */.
- Example: C has
Example Maps
nnoremap \\ :<C-U>silent lua require('blockformatter.block_comment').toggle_comment_normal(vim.v.count1)<CR>
vnoremap \\ :<C-U>silent lua require('blockformatter.block_comment').toggle_comment_visual()<CR>
Supported filetypes
- Javascript
- Dockerfile
- sshconfig
- Markdown
- groovy
- Python
- golang
- Rust
- Ruby
- Bash
- Yaml
- Toml
- HTML
- Lua
- Cpp
- CSS
- Zig
- Vim
- sh
- C
Block Alignment
Example Maps
nnoremap <leader>ba :<C-U>silent lua require("blockformatter.block_align").token_align_auto()<CR>
vnoremap <leader>ba :<C-U>silent lua require("blockformatter.block_align").token_align_visual()<CR>


