" Sample config for pb071 students, available at fi.muni.cz/pb071 " =============================================================== " Requires VIM-8.0 to enable linting, on aisa run: " $ module add vim-8.0 " However, the linting will fail silently, if version is older. " " Comes with plugin manager Plug: we added 2 colorschemes " and linting plugin ALE, which uses clang-tidy and gcc " to highlight some syntax errors. " " Install Plug first in bash: " $ curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim " Then run vim and install the plugins using command in normal mode: " :PlugInstall " " Most of the settings come from vimconfig.com. " We added few handy key mappings: " " Ctrl+Up/Down Move line or a block of selected lines " Ctrl+j/k " pp Toggle paste mode on and off " Disable search highlight " " is carriage return, "Enter" " is backspace, "\", complete the combination in 1 second set nocompatible set encoding=utf-8 """"" """"" Plugin manager Plug from https://github.com/junegunn/vim-plug """"" call plug#begin('~/.vim/plugged') " Plug 'vim-airline/vim-airline' " status bar mod Plug 'tomasiser/vim-code-dark' " colorscheme codedark Plug 'romainl/Apprentice' " colorscheme apprentice Plug 'w0rp/ale' call plug#end() " Setup linting for c99 let g:ale_completion_enabled = 1 let g:ale_linters = {'c': ['gcc', 'clangtidy', 'clang-format']} let g:ale_c_gcc_executable = 'gcc' let g:ale_c_gcc_options = '-std=c99 -Wall -Wextra -pedantic' let g:ale_c_clang_executable = 'gcc' let g:ale_c_clang_options = '-std=c99 -Wall -Wextra -pedantic' let g:ale_c_clangtidy_executable = 'clang-tidy' let g:ale_c_clangtidy_options = '-std=c99 -Wall -Wextra -pedantic' """"" """"" Colors """"" syntax on " Color schemes belong to ~/.vim/colors " Find yours at https://vimcolors.com colorscheme codedark " If using plugin vim-airline " let g:airline_theme = 'codedark' if &term =~ '256color' " disable Background Color Erase (BCE) so that color schemes " render properly when inside 256-color tmux and GNU screen. " see also http://snk.tuxfamily.org/log/vim-256color-bce.html set t_ut= endif " If you happen to still have a problem on some terminal, uncomment: " set t_Co=256 " set t_ut= " Color 81. character in line to visualize long lines highlight ColorColumn ctermbg=magenta call matchadd('ColorColumn', '\%81v', 100) """"" """"" General """"" set number " Show line numbers set linebreak " Break lines at word (requires Wrap lines) set showbreak=+++ " Wrap-broken line prefix set textwidth=100 " Line wrap (number of cols) set showmatch " Highlight matching brace set showcmd " Show last command on right set cursorline " Highlight current line set hlsearch " Highlight all search results set smartcase " Enable smart-case search set ignorecase " Always case-insensitive set incsearch " Searches for strings incrementally set autoindent " Auto-indent new lines set cindent " Use 'C' style program indenting set shiftwidth=4 " Number of auto-indent spaces set smartindent " Enable smart-indent set smarttab " Enable smart-tabs set softtabstop=4 noexpandtab " Number of spaces per Tab set wrap " Wrap lines """"" """"" Advanced """"" set ruler " Show row and column ruler information set undolevels=1000 " Number of undo levels set backspace=indent,eol,start " Backspace behaviour """"" """"" Key mapping """"" " Move lines using Ctrl+Up/Down in normal, insert and visual modes nnoremap :m-2 nnoremap :m+ inoremap :m-2 inoremap :m+ vnoremap :m '<-2gv=gv vnoremap :m '>+1gv=gv " or Ctrl+j/k nnoremap :m .+1== nnoremap :m .-2== inoremap :m .+1==gi inoremap :m .-2==gi vnoremap :m '>+1gv=gv vnoremap :m '<-2gv=gv " Toggle paste mode on and off " \ + pp map pp :setlocal paste! " Disable search highlight when is pressed map :noh