User Tools

Site Tools


linux:vim_dodger_setup

vim (vimrc)

Documentation
Name: vim (vimrc)
Description: vim configuration
Modification date :24/05/2018
Owner:dodger
Notify changes to: dodger
Tags:

Advanced vimrc (2022) edition

Globals

This is the initial vimrc file.

~/.vimrc
" ##############################################
" GLOBAL CONFIG
" ##############################################
set encoding=utf-8
set nocompatible      " We're running Vim, not Vi!
 
" map leader with , to start combos
let mapleader = ","

I'm remaping the leader key for convenience…

vim-plug

Use vim-plug as vundle is not maintained anymore…

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

patogen

The official instructions from https://github.com/tpope/vim-pathogen:

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
 
echo "execute pathogen#infect()" >> ~/.vimrc

PlugInstall command

Add to ~/.vimrc:

call plug#begin()
" The default plugin directory will be as follows:
"   - Vim (Linux/macOS): '~/.vim/plugged'
"   - Vim (Windows): '~/vimfiles/plugged'
"   - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
"   - e.g. `call plug#begin('~/.vim/plugged')`
"   - Avoid using standard Vim directory names like 'plugin'
 
" Make sure you use single quotes
 
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
 
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
 
" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
 
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
 
" Using a non-default branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
 
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }
 
" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
 
" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
 
" Unmanaged plugin (manually installed and updated)
"Plug '~/my-prototype-plugin'
 
Plug 'tpope/vim-sensible'
Plug 'junegunn/seoul256.vim'
 
Plug 'vim-syntastic/syntastic'
 
Plug 'mbbill/undotree'
 
" Initialize plugin system
call plug#end()

Then call the installation:

:PlugInstall

That will install all the above plugins:

  • junegunn/vim-easy-align
  • SirVer/ultisnips
  • scrooloose/nerdtree,
  • tpope/vim-fireplace,
  • rdnetto/YCM-Generator,
  • fatih/vim-go,
  • nsf/gocode,
  • junegunn/fzf,
  • tpope/vim-sensible
  • junegunn/seoul256.vim
  • vim-syntastic/syntastic
  • mbbill/undotree

Additional syntax/configs

Tagbar

Used for function/classes navigation [https://preservim.github.io/tagbar/|link].

cd ~/.vim/bundle
git clone https://github.com/preservim/tagbar.git

And add to ~/.vimrc:

" tagbar 
nmap <F8> :TagbarToggle<CR>

terraform syntax

From https://github.com/hashivim/vim-terraform using patogen:

git clone https://github.com/hashivim/vim-terraform.git ~/.vim/bundle/vim-terraform

Puppet syntax

From https://github.com/rodjek/vim-puppet using pathogen :

git clone https://github.com/rodjek/vim-puppet.git ~/.vim/bundle/vim-puppet

Plugin config files

" NERD commenter
source ~/.vim/pluginconf/nerd_commenter.vim
 
" syntastic
source ~/.vim/pluginconf/syntastic.vim
 
" undotree
source ~/.vim/pluginconf/undotree.vim
 
" nerdtree
source ~/.vim/pluginconf/nerdtree.vim
~/.vim/pluginconf/nerd_commenter.vim
" Create default mappings
let g:NERDCreateDefaultMappings = 1
 
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
 
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
 
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
 
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
 
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
 
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
 
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
 
" Enable NERDCommenterToggle to check all selected lines is commented or not 
let g:NERDToggleCheckAllLines = 1
 
" map leader with , to start combos
let mapleader = ","
~/.vim/pluginconf/syntastic.vim
"                ,
"               / \,,_  .'|
"            ,{{| /}}}}/_.'            _____________________________________________
"           }}}}` '{{'  '.            /                                             \
"         {{{{{    _   ;, \          /            Ladies and Gentlemen,              \
"      ,}}}}}}    /o`\  ` ;)        |                                                |
"     {{{{{{   /           (        |                 this is ...                    |
"     }}}}}}   |            \       |                                                |
"    {{{{{{{{   \            \      |                                                |
"    }}}}}}}}}   '.__      _  |     |    _____             __             __  _      |
"    {{{{{{{{       /`._  (_\ /     |   / ___/__  ______  / /_____ ______/ /_(_)____ |
"     }}}}}}'      |    //___/   --=:   \__ \/ / / / __ \/ __/ __ `/ ___/ __/ / ___/ |
" jgs `{{{{`       |     '--'       |  ___/ / /_/ / / / / /_/ /_/ (__  ) /_/ / /__   |
"      }}}`                         | /____/\__, /_/ /_/\__/\__,_/____/\__/_/\___/   |
"                                   |      /____/                                    |
"                                   |                                               /
"                                    \_____________________________________________/
" 
 
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
 
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
~/.vim/pluginconf/undotree.vim
" https://github.com/mbbill/undotree/blob/master/plugin/undotree.vim
"=================================================
"Options:
 
" Window layout
" style 1
" +----------+------------------------+
" |          |                        |
" |          |                        |
" | undotree |                        |
" |          |                        |
" |          |                        |
" +----------+                        |
" |          |                        |
" |   diff   |                        |
" |          |                        |
" +----------+------------------------+
" Style 2
" +----------+------------------------+
" |          |                        |
" |          |                        |
" | undotree |                        |
" |          |                        |
" |          |                        |
" +----------+------------------------+
" |                                   |
" |   diff                            |
" |                                   |
" +-----------------------------------+
" Style 3
" +------------------------+----------+
" |                        |          |
" |                        |          |
" |                        | undotree |
" |                        |          |
" |                        |          |
" |                        +----------+
" |                        |          |
" |                        |   diff   |
" |                        |          |
" +------------------------+----------+
" Style 4
" +-----------------------++----------+
" |                        |          |
" |                        |          |
" |                        | undotree |
" |                        |          |
" |                        |          |
" +------------------------+----------+
" |                                   |
" |                            diff   |
" |                                   |
" +-----------------------------------+
if !exists('g:undotree_WindowLayout')
    let g:undotree_WindowLayout = 2
endif
 
if has("persistent_undo")
   let target_path = expand('~/.vim/undodir')
 
    " create the directory and any parent directories
    " if the location does not exist.
    if !isdirectory(target_path)
        call mkdir(target_path, "p", 0700)
    endif
 
    let &undodir=target_path
    set undofile
endif
 
nnoremap <Leader>u :UndotreeToggle<CR>

Disabled, using FZF

~/.vim/pluginconf/nerdtree.vim
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>

FZF:

~/.vim/pluginconf/fzf.vim
" https://github.com/junegunn/fzf/blob/master/README-VIM.md
nnoremap <leader>f :FZF<CR>
let g:fzf_action = {
  \ 'ctrl-t': 'tab split',
  \ 'ctrl-x': 'split',
  \ 'ctrl-v': 'vsplit' }

Cheatsheet generated

In my config:

  • leader is ,
  • <C> is control key
##############'Shortcut'############## ##############command executed############## ——————————————————————
<leader>f :FZF<CR> Open fzf
inside fzf → <C-t> g:fzf_action 'tab split'<CR> Tab split selected file
inside fzf → <C-x> g:fzf_action 'split'<CR> split selected file
inside fzf → <C-v> g:fzf_action 'vsplit'<CR> vsplit selected file
<leader>u :UndotreeToggle<CR> Toggle Undotree pannel
<leader>b :BuffergatorOpen<CR> Open Buffergator pannel
[count]<leader>cc :NERDCommenterComment Comment out the current line or text selected in visual mode.
[count]<leader>cn :NERDCommenterNested Same as cc but forces nesting.
[count]<leader>c<space> :NERDCommenterToggle Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa.
[count]<leader>cm :NERDCommenterMinimal Comments the given lines using only one set of multipart delimiters.
[count]<leader>ci :NERDCommenterInvert Toggles the comment state of the selected line(s) individually.
[count]<leader>cs :NERDCommenterSexy Comments out the selected lines with a pretty block formatted layout.
[count]<leader>cy :NERDCommenterYank Same as cc except that the commented line(s) are yanked first.
<leader>c$ :NERDCommenterToEOL Comments the current line from the cursor to the end of line.
<leader>cA :NERDCommenterAppend Adds comment delimiters to the end of line and goes into insert mode between them.
<leader>ca :NERDCommenterAltDelims Switches to the alternative set of delimiters.
[count]<leader>cl :NERDCommenterAlignLeft Same as :NERDCommenterComment except that the delimiters are aligned down the left side (<leader>cl) or both sides (<leader>cb).
[count]<leader>cb :NERDCommenterAlignBoth Same as :NERDCommenterComment except that the delimiters are aligned down the left side (<leader>cl) or both sides (<leader>cb).
[count]<leader>cu :NERDCommenterUncomment Uncomments the selected line(s).

Simple vimrc

.vimrc
" URL: http://vim.wikia.com/wiki/Example_vimrc
" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode
" Description: A minimal, but feature rich, example .vimrc. If you are a
"              newbie, basing your first .vimrc on this file is a good choice.
"              If you're a more advanced user, building your own .vimrc based
"              on this file is still a good idea.
 
"------------------------------------------------------------
" Features {{{1
"
" These options and commands enable some very useful features in Vim, that
" no user should have to live without.
 
" Set 'nocompatible' to ward off unexpected things that your distro might
" have made, as well as sanely reset options when re-sourcing .vimrc
set nocompatible
 
" Attempt to determine the type of a file based on its name and possibly its
" contents. Use this to allow intelligent auto-indenting for each filetype,
" and for plugins that are filetype specific.
filetype indent plugin on
 
" Enable syntax highlighting
syntax on
 
 
"------------------------------------------------------------
" Must have options {{{1
"
" These are highly recommended options.
 
" Vim with default settings does not allow easy switching between multiple files
" in the same editor window. Users can use multiple split windows or multiple
" tab pages to edit multiple files, but it is still best to enable an option to
" allow easier switching between files.
"
" One such option is the 'hidden' option, which allows you to re-use the same
" window and switch from an unsaved buffer without saving it first. Also allows
" you to keep an undo history for multiple files when re-using the same window
" in this way. Note that using persistent undo also lets you undo in multiple
" files even in the same window, but is less efficient and is actually designed
" for keeping undo history after closing Vim entirely. Vim will complain if you
" try to quit without saving, and swap files will keep you safe if your computer
" crashes.
set hidden
 
" Note that not everyone likes working this way (with the hidden option).
" Alternatives include using tabs or split windows instead of re-using the same
" window as mentioned above, and/or either of the following options:
" set confirm
" set autowriteall
 
" Better command-line completion
set wildmenu
 
" Show partial commands in the last line of the screen
set showcmd
 
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the
" mapping of <C-L> below)
set hlsearch
 
" Modelines have historically been a source of security vulnerabilities. As
" such, it may be a good idea to disable them and use the securemodelines
" script, <http://www.vim.org/scripts/script.php?script_id=1876>.
" set nomodeline
 
 
"------------------------------------------------------------
" Usability options {{{1
"
" These are options that users frequently set in their .vimrc. Some of them
" change Vim's behaviour in ways which deviate from the true Vi way, but
" which are considered to add usability. Which, if any, of these options to
" use is very much a personal preference, but they are harmless.
 
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
 
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
 
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
 
" Stop certain movements from always going to the first character of a line.
" While this behaviour deviates from that of Vi, it does what most users
" coming from other editors would expect.
set nostartofline
 
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
 
" Always display the status line, even if only one window is displayed
set laststatus=2
 
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
 
" Use visual bell instead of beeping when doing something wrong
set visualbell
 
" And reset the terminal code for the visual bell. If visualbell is set, and
" this line is also included, vim will neither flash nor beep. If visualbell
" is unset, this does nothing.
set t_vb=
 
" Enable use of the mouse for all modes
" set mouse=a
 
" Set the command window height to 2 lines, to avoid many cases of having to
" "press <Enter> to continue"
set cmdheight=2
 
" Display line numbers on the left
set number
 
" Quickly time out on keycodes, but never time out on mappings
set notimeout ttimeout ttimeoutlen=200
 
" Use <F11> to toggle between 'paste' and 'nopaste'
set pastetoggle=<F11>
 
 
"------------------------------------------------------------
" Indentation options {{{1
"
" Indentation settings according to personal preference.
 
" Indentation settings for using 4 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set shiftwidth=4
set softtabstop=4
set expandtab
 
" Indentation settings for using hard tabs for indent. Display tabs as
" four characters wide.
"set shiftwidth=4
"set tabstop=4
 
 
"------------------------------------------------------------
" Mappings {{{1
"
" Useful mappings
 
" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
" which is the default
map Y y$
 
" Map <C-L> (redraw screen) to also turn off search highlighting until the
" next search
nnoremap <C-L> :nohl<CR><C-L>
 
"------------------------------------------------------------

Advanced vimrc

vundle & pathogen

Vundle is a plugin manager for vim.
Very simple tutorial for initial steps.

Official web: https://github.com/VundleVim/Vundle.vim
Pathogen is a runtime plugin manager

mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
cd ~/.vim/bundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

This vimrc is just the beginning, at the end of this page will be a finished one!

vimrc
" ##################################################
" 256 colors :-)
set t_Co=256
" ##################################################
 
 
" ##################################################
" pathogen
" ##################################################
execute pathogen#infect()
syntax on
"
" ##################################################
" ##################################################
" VUNDLE
" ##################################################
" ##################################################
"
set nocompatible              " be iMproved, required
filetype off                  " required
 
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
 
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
 
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" dodger: Disabled, needs ruby
"Plugin 'git://git.wincent.com/command-t.git'
 
 
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
 
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
 
 
"
" ##################################################
" ##################################################
" VUNDLE
" ##################################################
" ##################################################

Then run inside vim:

:PluginInstall

Plugins

Plugin config goes to:

mkdir ~/.vim/pluginconf

neocomplcache

Using neocomplcache as:

Official documentation:

Add default config to:

~/.vim/pluginconf/neocomplcache.vim
neocomplcache.vim
"Note: This option must set it in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
 
" Enable heavy features.
" Use camel case completion.
"let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
"let g:neocomplcache_enable_underbar_completion = 1
 
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
    \ 'default' : '',
    \ 'vimshell' : $HOME.'/.vimshell_hist',
    \ 'scheme' : $HOME.'/.gosh_completions'
        \ }
 
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
    let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
 
" Plugin key-mappings.
inoremap <expr><C-g>     neocomplcache#undo_completion()
inoremap <expr><C-l>     neocomplcache#complete_common_string()
 
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
  return neocomplcache#smart_close_popup() . "\<CR>"
  " For no inserting <CR> key.
  "return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y>  neocomplcache#close_popup()
inoremap <expr><C-e>  neocomplcache#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplcache#close_popup() : "\<Space>"
 
" For cursor moving in insert mode(Not recommended)
"inoremap <expr><Left>  neocomplcache#close_popup() . "\<Left>"
"inoremap <expr><Right> neocomplcache#close_popup() . "\<Right>"
"inoremap <expr><Up>    neocomplcache#close_popup() . "\<Up>"
"inoremap <expr><Down>  neocomplcache#close_popup() . "\<Down>"
" Or set this.
"let g:neocomplcache_enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplcache_enable_insert_char_pre = 1
 
" AutoComplPop like behavior.
"let g:neocomplcache_enable_auto_select = 1
 
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplcache_enable_auto_select = 1
"let g:neocomplcache_disable_auto_complete = 1
"inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
 
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
 
" Enable heavy omni completion.
if !exists('g:neocomplcache_force_omni_patterns')
  let g:neocomplcache_force_omni_patterns = {}
endif
let g:neocomplcache_force_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplcache_force_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplcache_force_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
 
" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplcache_force_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::'

And add to vimrc:

source ~/.vim/pluginconf/neocomplcache.vim

YouCompleteMe

Official install guide:

Pre-Requirements:

  • jdk for java completion
  • mono for c# completion
  • node.js for javascript completion
apt-get install build-essential cmake python3-dev
apt-get install apt-file
apt-get install mono-devel mono-runtime
apt-get install openjdk-8-jdk
curl -sL https://deb.nodesource.com/setup_10.x | bash
apt-get install -y nodejs
python3 ./install.py --clang-completer --cs-completer --ts-completer --java-completer

UndoTree

Make dir to store the changes:

mkdir ~/.vim/undodir

Add default config to:

~/.vim/pluginconf/undotree.vim
undotree.vim
if has("persistent_undo")
    set undodir=~/.vim/undodir/
    set undofile
endif

And add to vimrc:

source ~/.vim/pluginconf/undotree.vim

Syntastic

Syntastic is a syntax checking plugin for Vim.
official github page

Add default config to:

~/.vim/pluginconf/syntastic.vim
syntastic.vim
"                ,
"               / \,,_  .'|
"            ,{{| /}}}}/_.'            _____________________________________________
"           }}}}` '{{'  '.            /                                             \
"         {{{{{    _   ;, \          /            Ladies and Gentlemen,              \
"      ,}}}}}}    /o`\  ` ;)        |                                                |
"     {{{{{{   /           (        |                 this is ...                    |
"     }}}}}}   |            \       |                                                |
"    {{{{{{{{   \            \      |                                                |
"    }}}}}}}}}   '.__      _  |     |    _____             __             __  _      |
"    {{{{{{{{       /`._  (_\ /     |   / ___/__  ______  / /_____ ______/ /_(_)____ |
"     }}}}}}'      |    //___/   --=:   \__ \/ / / / __ \/ __/ __ `/ ___/ __/ / ___/ |
" jgs `{{{{`       |     '--'       |  ___/ / /_/ / / / / /_/ /_/ (__  ) /_/ / /__   |
"      }}}`                         | /____/\__, /_/ /_/\__/\__,_/____/\__/_/\___/   |
"                                   |      /____/                                    |
"                                   |                                               /
"                                    \_____________________________________________/
" 
 
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
 
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

And add to vimrc:

source ~/.vim/pluginconf/syntastic.vim

python syntax check

As pre-requirement :

  • syntastic plugin
  • a syntax checker like pyflakes (for example)

So install pyflakes for example:

yum -y install pyflakes

Add this configfile to the pluginconf folder:

syntastic_python.vim
let g:syntastic_python_checkers = ['pyflakes']

And add to vimrc:

source ~/.vim/pluginconf/syntastic_python.vim

python omnicompletion

Official web

Install:

curl "https://www.vim.org/scripts/download_script.php?src_id=10872" > ~/.vim/pluginconf/pythoncomplete.vim
echo "source ~/.vim/pluginconf/pythoncomplete.vim" >> ~/.vimrc

tagbar

Official web Install:

  • clone the repo

Add this configfile to the pluginconf folder:

tagbar.vim
nmap <F8> :TagbarToggle<CR>

And add to vimrc:

source ~/.vim/pluginconf/tagbar.vim

airline

Webs:

Install:

  • clone the repos

Add this configfile to the pluginconf folder:

airline.vim
if !exists('g:airline_symbols')
  let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
 
let g:airline_powerline_fonts = 1
 
let g:airline_theme='molokai'

And add to vimrc:

source ~/.vim/pluginconf/airline.vim

Special mapppings

I've remapped the leader key to , (instead of \) with

let mapleader = ","

That way, we can add useful shortcuts like

  • :UndoTreeToggle
nnoremap <Leader>u :UndotreeToggle<CR>
  • :TagbarToggle
nnoremap <Leader>f :TagbarToggle<CR>

vim on debian

Some plugins requires vim to be compiled with +python BUT vim usually is not build with that option.
In debian (VDI) you can install vim-nox package. Then reconfigure system and choose it:

update-alternatives --config editor
linux/vim_dodger_setup.txt · Last modified: 2022/04/21 08:34 by dodger