Last active
May 4, 2021 13:00
-
-
Save r10r/97539a5556ef6dfb26b30fa43ca21b19 to your computer and use it in GitHub Desktop.
My vim config file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" location of this file | |
" global (debian): /etc/vim/vimrc.local | |
" user: ~/.vimrc | |
" Avoid that defaults overwrite custom configuration | |
" see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837761 | |
" run ':scriptnames' to show the import order | |
let skip_defaults_vim=1 | |
source $VIMRUNTIME/defaults.vim | |
syntax on | |
" Uncomment the following to have Vim jump to the last position when reopening a file | |
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | |
" Uncomment the following to have Vim load indentation rules and plugins | |
" according to the detected filetype. | |
filetype plugin on | |
filetype plugin indent on | |
" The following are commented out as they cause vim to behave a lot | |
" differently from regular Vi. They are highly recommended though. | |
"set showcmd " Show (partial) command in status line. | |
set showmatch " Show matching brackets. | |
"set ignorecase " Do case insensitive matching | |
"set smartcase " Do smart case matching | |
"set incsearch " Incremental search | |
set autowrite " Automatically save before commands like :next and :make | |
"set hidden " Hide buffers when they are abandoned | |
"set mouse=a " Enable mouse usage (all modes) | |
colorscheme elflord | |
"http://stackoverflow.com/questions/11489428/how-to-make-vim-paste-from-and-copy-to-systems-clipboard | |
" linux: install 'vim-gtk' for xterm_clipboard capability | |
set clipboard=unnamed | |
" fix backspace problems with vim installed from homebrew | |
" see http://vim.wikia.com/wiki/Backspace_and_delete_problems | |
set backspace=2 " make backspace work like most other apps | |
set backspace=indent,eol,start | |
" show line numbers by default | |
set number | |
set hlsearch | |
" disable incremental search during typing (enabled by default in debian | |
" testing with version 8 but not on osx ?) | |
set noincsearch | |
" disable interactive mouse that makes copy paste impossible in iterm | |
set mouse-=a | |
" Map F2 to 'paste|nopaste' toggle | |
" The paste toggle is especially usefull to disable auto-indentation temporarily | |
nnoremap <F2> :set invpaste paste?<CR> | |
set pastetoggle=<F2> | |
set showmode | |
" enable folding for markdown documents, but start unfolded | |
let g:markdown_folding=1 | |
autocmd FileType markdown setlocal foldlevel=99 | |
" show all characters see ':h conceallevel' | |
set conceallevel=2 | |
" highlight trailing whitespace | |
" see https://vim.fandom.com/wiki/Highlight_unwanted_spaces | |
highlight ExtraWhitespace ctermbg=3c3c3c guibg=lightgreen | |
"highlight ExtraWhitespace ctermbg=240 guibg=lightgreen | |
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red | |
match ExtraWhitespace /\s\+$/ | |
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ | |
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/ | |
autocmd InsertLeave * match ExtraWhitespace /\s\+$/ | |
autocmd BufWinLeave * call clearmatches() | |
" >>>> Plugin Settings | |
" | |
" Plugin: vim-go | |
" Install: git clone https://github.com/r10r/vim-go.git ~/.vim/pack/vendor/start/vim-go | |
" cc: jump to first error | |
map <C-n> :cnext<CR> | |
map <C-m> :cprevious<CR> | |
nnoremap <leader>a :cclose<CR> | |
autocmd FileType go nmap <leader>b <Plug>(go-build) | |
" navigation works for GoFmt with this | |
let g:go_list_type = "quickfix" | |
" see https://github.com/fatih/vim-go/pull/1415 | |
" let g:go_list_type_commands = {"GoFmt": "quickfix" } | |
" Plugin: yaml-vim | |
" Doc: https://tpaschalis.github.io/yaml-vim/ | |
" Install: git clone https://github.com/r10r/yaml-vim.git ~/.vim/pack/vendor/start/yaml-vim | |
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab indentkeys-=0# | |
" Plugin: indentLine | |
" Install: git clone https://github.com/r10r/indentLine.git ~/.vim/pack/vendor/start/indentLine | |
" let g:indentLine_char = '⦙' | |
" NOTE: Only enable this for 'yaml' files. The plugin enables conceallevel=2 by default. | |
" This hides tokens used for syntax highlighting (e.g in markdown). | |
" see https://vi.stackexchange.com/questions/7258/how-do-i-prevent-vim-from-hiding-symbols-in-markdown-and-json/31059#31059 | |
let g:indentLine_fileType = ['yaml'] | |
" Plugin: vim-shfmt | |
" Description: Runs shfmt to auto format the current buffer by a command :Shfmt | |
" Install: git clone https://github.com/r10r/vim-shfmt.git ~/.vim/pack/vendor/start/vim-shfmt | |
let g:shfmt_fmt_on_save = 1 | |
" General advice: Indent with tabs, align with spaces. | |
" The linux kernel coding convention is special and uses 8 spaces for indentation. | |
set copyindent | |
set preserveindent | |
set softtabstop=4 | |
set shiftwidth=4 | |
set tabstop=4 | |
" Show tabs in shell scripts | |
" Heredocs can be indented by tabs. Set 'noet' to disable tab expansion when | |
" indenting a heredoc | |
"autocmd FileType sh setlocal list listchars=tab:>. | |
autocmd FileType sh setlocal noexpandtab | |
" Plugin: vim-clang-format | |
" Description: Formats your code with specific coding style using clang-format. | |
" Install: git clone https://github.com/r10r/vim-clang-format.git ~/.vim/pack/vendor/start/vim-clang-format | |
" autocmd FileType c ClangFormatAutoEnable | |
" autocmd FileType c setlocal list listchars=tab:>. | |
autocmd FileType c setlocal noexpandtab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment