Konstantin Epishev
Posted on December 26, 2019
Some years ago vim was for me an unreachable text editor for "real hackers" and I really had not any ideas how to use it and how it can be useful in the daily development.
But now I can't imagine other editor, because I have finally tame vim!
There are some steps which I have done before start using vim efficiently.
Use "all fingers"
Before vim
I had used only 4 or 5 fingers in the "blind mode" and when I have started practicing with ten-fingers input – text navigation with arrows became just uncomfortable for me.
It was key moment, when I began to think about migration to vim
.
How I have started using all fingers? Just start do that. I have used some keyboard trainers, but only for adapt to keyboard layout. Type with all fingers, look at keyboard when you need that, but just try to use all fingers on right positions.
It took ~1 month for me before I stopped feeling discomfort.
Complete vimtutor
vimtutor
is a educational program with basics of vim
usage. Before it I had not any knowledge about navigation except h
, j
, k
, l
keys.
I highly recommend to complete vimtutor
at the beginning, because it can give you a strong basement of vim usage in the future.
Disable arrows keys
It is very important because I had a huge temptation to start using arrows in vim
. Just disable them for acceleration of adaptation to the new navigation way.
" Disable arrows in visual and normal modes
map <Up> <Nop>
map <Down> <Nop>
map <Left> <Nop>
map <Right> <Nop>
" Disable arrows in input mode
imap <Up> <Nop>
imap <Down> <Nop>
imap <Left> <Nop>
imap <Right> <Nop>
Use existing config
The first thing, which I knew about vim
was possibility to customize editor for your own purposes.
I had already installed NeoVim and vim-plug and with existing configs I have tried to reproduce my favorite features from past text editors in vim.
As example I took configuration of one local engineer Sergey Golovin. It includes all basic features which can be helpful at the beginning, because in future you will configure editor for yourself.
You also can try to use my vim configuration, but I'm periodically changing it.
Bring features from your favorite editor
So, I had a lot of troubles with understanding buffers, search and replace operations, navigation between files and at the first two weeks I had a strong desire to start using Sublime Text again.
But I have discovered tabs, some plugins for reproducing favorite features like fuzzy search or navigation between opened files.
There are some vim
plugins "mapped by features":
fzf.vim
provides project-wide fuzzy search, search between active buffers and etc. It can be customized.
If you want to exclude all files from .gitignore
you should add to your init.vim
following line:
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
You can use other search utility, like ripgrep instead ag
.
This plugin provides features similar to fzf.vim
. I have used it at the first time but then have changed it to fzf.vim
plugin.
I really like search in Sublime Text and ctrlsf.vim
fully reproduce it in vim.
You can find something in project and change something right in results. It is really awesome, useful and visual.
nerdtree
provides visual navigation between project files and basic filesystem manipulations (create, delete, rename, move, etc.).
I'm using it with vim-nerdtree-sync, because I want to see active file in project tree.
coc.vim
provides autocomplete engine like VS Code to vim
. It just works.
Before using you should install neovim
npm package globally:
npm install -g neovim
It is using plugins system. For example, if you want to use typescript
or javascript
autocompletion, you should run :CocInstall coc-tsserver
.
I'm using tab
and shift+tab
for navigation between completion items:
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
inoremap <expr><S-tab> pumvisible() ? "\<c-p>" : "\<S-tab>"
Plugins which I have described above are very useful for daily tasks, but you can find other plugins on vimawesome or write your own with vim script (it is not so difficult).
Survive the first two weeks
It is the most difficult step. Before that try to make basic vim
configuration with all required features and then use that. If you meet with some problems – make note about that and then try to solve with plugin or just on configuration level.
If you are not ready to use vim
as main editor – install keymap for your current editor and accustom with navigation and other features. It is much simpler for beginners.
Conclusion
I have met with vim
a lot of years ago and have thought that it is very difficult all this time, but it is not difficult, it is just different and if you want to start use vim
you can do that easily in few weeks!
So, my next target is spacemacs. When I want to start new migration? I don't know, but when I will do that – I will tell about that experience! 🦄
Posted on December 26, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.