Make json human readable
:%!python -m json.tool
Auto Indent Entire File
If you want to autoindent a file you're on, use the following keyboard shortcut:
So basically you use gg to get to the start of the file, = to indent and G to get to the end of the file.
Delete all text in a file
If you want to delete all of the text in file you're in, use the following keyboard shortcut:
Alternative to esc
Alternative to wq!
Alternative to q!
Indent once in normal mode:
Repeat the indent:
Indent five times:
Ctrl-T to indent in insert mode
Ctrl-D to unindent in insert mode
Password protect a file
vim -x file.txt
To set a strong encryption method, run this while the file is open:
Open the file and do the following:
- Press the enter key twice