set encoding=utf8 scriptencoding utf8 lang en_US.UTF-8 " ---------------------- " --- PLUGINS " ---------------------- call plug#begin() Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' Plug 'jremmen/vim-ripgrep' Plug 'tpope/vim-commentary' Plug 'tpope/vim-surround' Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']} Plug 'SirVer/ultisnips' call plug#end() " ---------------------- " --- GENERAL " ---------------------- " use space as key let mapleader=" " set nu set relativenumber " syntax highlighting syntax on filetype plugin indent on " vertical bar in insert mode, block in normal mode let &t_SI = "\e[6 q" let &t_EI = "\e[2 q" set backspace=indent,eol,start " indentation set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab set smartindent set autoindent " copy paste clipboard set clipboard=unnamed " highlight current line set cursorline " searching set incsearch set ignorecase set smartcase set nohlsearch " display title of current file in terminal title bar set title " allow hidden buffers set hidden " dont wrap long lines set nowrap " disable swaps and backups set noswapfile set nobackup set nowritebackup " start scrolling when 8 lines left set scrolloff=8 " show sign column set signcolumn=yes " show the colorcolumn set colorcolumn=80 " :sp and :vsp should split below and to the right set splitbelow set splitright " avoid delays when typing set updatetime=50 " enable mouse support set mouse=a " shows a more advanced command-line completion menu set wildmenu " Modifies the auto-complete menu. See :h completeopt set completeopt="noinsert,menuone,noselect" " show whitespace characters set list lcs=tab:>\ ,trail:~,precedes:<,space:\ ,nbsp:× " --------------------------------- " --- STATUSLINE " -------------------------------- function! GitBranch() return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'") endfunction function! StatuslineGit() let l:branchname = GitBranch() return strlen(l:branchname) > 0?' '.l:branchname.' ':'' endfunction set laststatus=2 set statusline= set statusline+=%#PmenuSel# set statusline+=%{StatuslineGit()} set statusline+=%#CursorColumn# set statusline+=\ %f set statusline+=%m\ set statusline+=%= set statusline+=\ %y set statusline+=\ %p%% set statusline+=\ %l:%c set statusline+=\ " --------------------------------- " --- AUTOCOMMANDS " -------------------------------- " set correct filetype for terraform files autocmd BufRead,BufNewFile *.tf,*.tfvars set filetype=terraform " set correct comment string for powershell files autocmd FileType ps1 setlocal commentstring=#\ %s " reload file if changes from outside autocmd FocusGained,BufEnter * :checktime " --------------------------------- " --- KEYBINDINGS " -------------------------------- " open file explorer nnoremap pv :Ex " copy the whole file and stay where you are nnoremap yy ggVGy " move visual line(s) up and down vnoremap J :m '>+1gv=gv vnoremap K :m '<-2gv=gv " move line up/down nnoremap :m-2 nnoremap :m+1 " keeps search in the middle (n=next, N=previous) nnoremap n nzzzv nnoremap N Nzzzv " keeps half page up/down in the middle nnoremap zz nnoremap zz " delete highlighted word/line into void and keeps the pasted value " in default registry so you can paste many times xnoremap p "_dp " delete to void nnoremap d "_d vnoremap d "_d " fzf nnoremap :GFiles nnoremap ff :Files nnoremap fg :Ag nnoremap ffg :Rg nnoremap b :Buffers " avoid human error cabbr W w cabbr Wq wq cabbr Q q cabbr E e " ---------------------- " --- SNIPPETS " ---------------------- let g:UltiSnipsSnippetDirectories=[$HOME.'/.local/snippets'] " ---------------------- " --- THEME " ---------------------- set background=dark colorscheme habamax " highlight extra whitespace highlight ExtraWhitespace ctermbg=red guibg=red autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@