Configure Vim Start Screen
The Vim start screen contains only information on how to start reading the documentation for this editor and how to exit it correctly. After all, as you know, many tools have a steep input curve, and Vim also has a steep output curve. Those who have already learned to exit Vim will probably want to make the start screen more informative and useful. What will we do.
Installation and basic setup
And the Startify plugin will help us with this .
I use Vundle to manage Vim plugins, so I added the following snippet to .vimrc:
Plugin 'mhinz/vim-startify'" Nice start screen
When starting Vim without specifying files to open, this plugin displays a start screen that lists files that were recently edited, as well as Vim's sessions. You can also specify a list of files that will always be present (bookmarks or bookmarks):
To open a file now just dial the number that is located next to the file in square dogs. A number of commands are also defined, for example:
e - create an empty buffer
i - create an empty buffer and switch to Insert mode
q - exit Vim
To specify files for bookmarks, you need to register them in .vimrc:
let g:startify_bookmarks = ['~/.vimrc',]
The plugin also allows you to specify the title of the start screen and footer. The documentation uses Fortunks and Cows as an example:
let g:startify_custom_header = map(split(system('fortune | cowsay'), '\n'), '" ". v:val') + ['','']
However, I do not really like this option. Firstly, fortors can sometimes contain quite a lot of lines and, as a result, occupy almost the entire screen. Secondly, I want to have themed Fortuns with Vim tips. Therefore, I took the vim-fortune file from the vimtips-fortune project , put it in ~ / .vim / fortunes and formed a dat-file:
After that, I added the following line to .vimrc
let g:startify_custom_header = \ map(split(system('fortune ~/.vim/fortunes | cowsay -W 60'), '\n'), '" ". v:val') + ['','']
Thus, we get a pretty good start screen:
Also, I started making my fortune file with tips on the plugins I use.
Configure working directory change
By default, when opening a file, the plugin sets Vim’s working directory to the directory of the file to be opened. Also, the plugin can be configured so that it switches to the root directory of the version control system of this project:
let g:startify_change_to_vcs_root = 1
Currently supported: git , hg , bzr , svn .
This behavior is also not always appropriate. For example, several of my projects have subprojects written in python. These files are located in separate subdirectories. When opening such python files, it would be more logical to switch to this particular subdirectory, and not to the root git. To implement this functionality, I use the vim-rooter plugin , which also changes the working directory when opening the file. The plugin can specify a list of marker files to be searched. Since I have tags tag files in my python subdirectories, I added it to the list:
let g:rooter_patterns = ['tags', '.git', '.git/']
Thus, with the help of the considered plug-ins, you can optimize the work with Vim.
In my .vimrc snippet with settings for vim-startify and vim-rooter:
" Startify let g:startify_change_to_dir = 0 let g:startify_files_number = 8 let g:startify_bookmarks = ['~/.vimrc',] let g:startify_skiplist = ['vimrc',] let g:startify_custom_header = map(split(system('fortune ~/.vim/fortunes | cowsay -W 60'), '\n'), '"". v:val') + ['',''] " Rooter let g:rooter_patterns = ['tags', '.git', '.git/']
I hope someone finds the information presented useful for themselves.