https://github.com/luk400/vim-emptyindent
Vim Plugin to indent empty lines to match following non-empty lines
https://github.com/luk400/vim-emptyindent
Last synced: 3 months ago
JSON representation
Vim Plugin to indent empty lines to match following non-empty lines
- Host: GitHub
- URL: https://github.com/luk400/vim-emptyindent
- Owner: luk400
- Created: 2020-12-31T13:16:53.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-25T10:33:00.000Z (almost 5 years ago)
- Last Synced: 2025-04-04T17:28:10.336Z (9 months ago)
- Language: Python
- Size: 2.84 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vim-emptyindent
Indents empty lines (i.e. lines with only a line break) in file to match indentation of corresponding next non-empty lines.
This tool was created because of a regular annoyance I experienced when working with python scripts in an interactive manner where I execute and interact with parts of the code analagously to when using e.g. jupyter-notebook.
I regularly work with vim and an open terminal running python in a split window mode, and send lines from the opened file to the terminal.
Often however, there are empty lines without indentation in the files I work with, which causes problems if there's e.g. such an empty line in a function definition, since it signals the end of the function when I send such a line to the python buffer.
This tool solves this problem by looking for the next non-empty line after each empty line in the file and adjusting the indentation to match that of the respective following non-empty line.


## Getting Started
### Requirements
* vim compiled with python3
### Installation
With your plugin manager of choice, e.g.:
```
Plug 'luk400/vim-emptyindent'
```
### Usage
By default, the mapping `in` is used to indent the currently opened file.
To define your own mapping, simply set
```
let g:indentempty_use_defaults = 0
```
in your .vimrc before the Plugin is loaded and set the desired mapping by substituting `in` in the following:
```
nmap in IndentCurrentFile
```
If you later want to remove the whitespaces in the indented empty lines again, you can do this by default using `rin`, or set your own mapping in your .vimrc by defining
```
nnoremap rin :%s/^\s\+$//g
```
where you substitute your own mapping for `rin`.