Vim is great. Despite its steep learning curve , it has many advantages and many loyal Vim followers will tell you that you should force yourself to use it.
Personally I started using Vim when I was ssh-ing into the group servers or into my computer in department. In such scenarios, I could not open the IDEs with the nice GUIs 🙁 However, as time passed, Vim started to grow on me. Now, I can list a few reasons why I think it is great, for example, it requires a small amount of memory to run, has a short start up time and can handle large files pretty well.
Although, I am definitely not a Vim expert, I will tell you about some of the things I have added to my .vimrc
. The .vimrc
file is very handy for containing all your favourite settings, such as key mappings, custom commands, formatting and syntax highlighting. The file uses vimscript which is a programming language in itself. However, there is a lot of help online that tells you with what lines to add to your .vimrc
. I would recommend installing Vundle which is a Vim plugin manager.
Here I will list some cool things that I have discovered you can do with your .vimrc
. It has certainly made my life a bit nicer.
- Code Folding
Most IDEs provide a way to collapse functions and classes that results in only seeing the function/class definition and hiding the code. To do this in Vim add the following lines to your.
vimrc
" Enable folding set foldmethod=indent set foldlevel=99 " Enable folding with the spacebar nnoremap <space> za
Alternatively, you can install the Vim plugin SimpylFold. - Python indentation
Vim does not do auto indention like many IDEs. To automatically do PEP-8 indentation for Python, add the following to your .vimrc .
" PEP indentation au BufNewFile,BufRead *.py \ set tabstop=4 \ set softtabstop=4 \ set shiftwidth=4 \ set textwidth=79 \ set expandtab \ set autoindent \ set fileformat=unix
You can also install the Vim plugin vim-flake8 which is a static syntax and style checker for Python source code. It shows errors in a quickfix window and lets you jump to their location inside your code.
- Turn line numbers on
Rather than typing in:set nu
every time you open your files. You can always have them turned on by adding :set nu to your.
vimrc
- Autocompletion
When I switch from PyCharm to Vim I feel a bit lost without the autocompletion however, after a quick search I found many are using the Vim package Youcompleteme and it is awesome.