Vim is my favorite editor. For everything. Python, Latex, Matlab, data-analysis, love-letters. Anything. Over the years, I have come to love several of VIM's features. Here is a continuously growing list for easy reference
There are times when we have many tabs, split windows, buffer-local commands and such defined for a given vim session. Why not save the state of this session for a later date when you get back to the same project? It is easy with mksession
Save the current session with this command
:mksession path-to-save-session-file-to
And when it is time to open up the session again, just fire up vim like this
vim -S path-to-load-session-file-from
For confidentiality, you can encrypt the contents of your file with vim. :X in normal mode prompts you for a key. You can also invoke vim with the -x flag to edit encrypted files. If you want utmost privacy, make sure you disable the use of a viminfo file. You can disable the use of viminfo file from the command-prompt by using the -i flag
vim -x -i '' filename
When you reopen the file, vim will request the key. If you provide an incorrect key, vim will return gibberish. You should also use the strongest possible encryption, which at this time is blowfish2
:set viminfo=
:setlocal cryptmethod=blowfish2
Note that you need to modify the file after setting the blowfish method so that it is re-encrypted using the method.
Insert current date and time stamp easily into a document with the put command
:put =strftime(\"%c\")
Do so often by mapping a key to the command
:nnoremap thekey "=strftime("%c")
Beginners can get started with vim by just firing up the command vimtutor on their terminal. It is a succinct and comprehensive reference for vim users.
Scroll bars are inefficient. Vim empowers Superman-like movement. You just have to know where to go.
Vim treats the following as objects and how they are denoted within commands
Use a combination of movement and action commands to work directly with objects.
Similarly, i and a can be used with other symbols (e.g. aw, as, and ip) to denote the corresponding object.
To ensure that you do not accidently write into a file that you only wish to read, open it in another buffer with :view /path/to/file. You can also open it another tab with :tab sview /path/to/file.
Help us create more concise and informative content and keep it free of paywalls and advertisements!