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.
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>
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 to1
would yield/* <line> */
.
- Example: C has
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>
- Javascript
- Dockerfile
- sshconfig
- Markdown
- groovy
- Python
- golang
- Rust
- Ruby
- Bash
- Yaml
- Toml
- HTML
- Lua
- Cpp
- CSS
- Zig
- Vim
- sh
- C
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>