Home

Awesome

Configuration for Vim 8+

This is a distribution of plugins and configuration to use Vim for development, on Linux and macOS. It uses vim-plug to manage the plugins automatically. The plugins are listed in bundle.vim, which is sourced by vimrc.

Most development support is now handled with language servers via coc.nvim. To enable this experimental configuration, set the environment variable VIM_CONFIG_USE_COC.

Installation

Clone the repository:

$ git clone https://github.com/smancill/vim-config.git ~/.vim

Execute the installation script (curl is required):

$ cd ~/.vim
$ ./install.sh

This script installs the plugin manager (vim-plug), downloads and installs the plugins, and downloads spell files for English and Spanish.

Prerequisites

<details> <summary>Some plugins need external programs to work properly <i>(click to expand/colapse)</i>.</summary>
Source code tags

You need the Universal Ctags program:

# Ubuntu
$ sudo apt install universal-ctags

# macOS
$ brew install universal-ctags

Press <F8> to open a lateral window with the tags of the current buffer ordered by scope, or use g[ to fuzzy search for a tag within the buffer.

Better grep

Install ack to use the :Ack[!] command inside Vim as a replacement for grep:

# Ubuntu
$ sudo apt install ack-grep

# macOS
$ brew install ack

See the webpage for more information. ripgrep is also supported (and recommended) as a replacement for ack if installed.

Syntax checking

ALE provides automatic syntax checking when saving the file.

C/C++ files have automatic support with GCC.

To add support for Python files install ruff:

# Ubuntu
$ pip install ruff

# macOS
$ brew install ruff

For shell script files, install ShellCheck:

# Ubuntu
$ sudo apt install shellcheck

# macOS
$ brew install shellcheck
</details>

Updating to the latest version

Fetch any changes from the repository:

$ cd ~/.vim
$ git pull origin master
$ ./install -u

The script will start vim and run :PlugUpdate to install new plugins and update the existing ones. See vim-plug documentation for more details.

Override and extend this configuration

To override settings, create a directory ~/.vim/vendor (for shared company-wide settings) or a directory ~/.vim/private (for private local settings). They will be added to the runtimepath. If both are used, the private settings will override those in vendor.

Override plugins

To add or remove plugins, create a file named ~/.vim/vendor/bundle.vim (for shared company-wide plugins) or ~/.vim/private/bundle.vim (for local-machine plugins), and put extra plugins in there:

" Remove ctrlp (UnPlug is defined in vimrc, not in vim-plug)
UnPlug 'kien/ctrlp.vim'

" Use fzf instead
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'

Override global settings

To extend or change the configuration of vimrc, create a file named ~/.vim/vendor/vimrc (for shared company-wide configuration) or ~/.vim/private/vimrc (for a local-machine configuration), and put extra settings in there:

" Override settings for plugins
let g:ale_cpp_cc_options = '-std=c++11'

" Override Vim settings
set nonumber
set noexpandtab
set tabstop=8

Override filetype settings, etc

Since ~/.vim/vendor and ~/.vim/private are added to the runtimepath, simply create the files in their expected locations, and they will be sourced by normal Vim initialization.

Examples:

Features

The vimrc sets the following options:

And several more.

Configuration for used plugins can be found in bundle.vim.

Navigating buffers

Vim uses buffers (:help buffers) to edit multiple files. Use the following key mappings in normal mode to easily work with buffers.

See Working with buffers, Working with windows and Working with tabs for a quick introduction to Vim features for editing multiple files.

Note that using tabs in Vim is different than opening tabs in other editors.

Useful mappings

Plugins

The following plugins are used (check bundle.vim for configuration details):