Vimrc
From Fiamma
Jump to navigationJump to search
My absolutely chaotic vimrc, with copy-pasted bits from random online sources.
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 'slim-template/vim-slim' " plugin from http://vim-scripts.org/vim/scripts.html Plugin 'L9' Plugin 'scrooloose/nerdtree' Plugin 'bling/vim-airline' " Bundle 'vim-ruby/vim-ruby' Plugin 'vim-scripts/CycleColor' Bundle 'bilalq/lite-dfm' Plugin 'junegunn/goyo.vim' Plugin 'terryma/vim-multiple-cursors' " Ctrl+n to trigger Plugin 'terryma/vim-expand-region' " + and _ to expand/shrink region " 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: " 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 " " SH syntax on let mapleader = "," set number "show line numbers set autoindent set hlsearch set incsearch inoremap , ,<Space> "Moving between splits map <leader>h :wincmd h<CR> map <leader>j :wincmd j<CR> map <leader>k :wincmd k<CR> map <leader>l :wincmd l<CR> "Relative number map <leader>r :set number relativenumber<CR> "Allow positioning cursor where there's no character in all modes set virtualedit = "all" " For the two languages map U :set keymap=ukrainian-dvorak<CR> map R :set keymap=russian-dvorak<CR> " For illustration purposes abbr psvm public static void main(String[] args){<CR>}<esc>O " https://stackoverflow.com/questions/9166328/how-to-copy-selected-lines-to-clipboard-in-vim " To share the clipboard between different vim instances set clipboard=unnamedplus "clear a line nnoremap -c ddO "Two enter two times nnoremap -s o<Return> set backspace=indent,eol,start colorscheme desert map <leader>p :set paste<CR> map <leader>. :set nopaste<CR> map <leader>' :quit<CR> map <leader><leader> :x<CR> ":imap rc <Esc> imap qj <Esc> imap ;q <Esc>:w<CR> imap jj <Esc>:x<CR> map <leader>s :w<CR> nnoremap -- o<Esc> set guioptions+=h "make it scroll lower than the visible lines set tabstop=2 set shiftwidth=2 filetype on " required by eclim map ; : noremap ;; ; " Tweaks from https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim " Auto read a file when changed from outside set autoread " :W sudo saves the file " (useful for handling the permission-denied error) command W w !sudo tee % > /dev/null " Set 7 lines to the cursor - when moving vertically using j/k set so=7 set wildmenu " Ignore compiled files set wildignore=*.o,*~,*.pyc if has("win16") || has("win32") set wildignore+=.git\*,.hg\*,.svn\* else set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store endif set ruler set cmdheight=2 " Configure backspace so it acts as it should act set backspace=eol,start,indent set whichwrap+=<,>,h,l " Ignore case when searching set ignorecase " When searching try to be smart about cases set smartcase " Don't redraw while executing macros (good performance config) set lazyredraw " Show matching brackets when text indicator is over them set showmatch " How many tenths of a second to blink when matching brackets set mat=2 " Add a bit extra margin to the left " set foldcolumn=1 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Text, tab and indent related """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Use spaces instead of tabs set expandtab " Be smart when using tabs ;) set smarttab " 1 tab == 4 spaces set shiftwidth=4 set tabstop=4 " Linebreak on 500 characters set lbr set tw=500 set ai "Auto indent set si "Smart indent set wrap "Wrap lines """""""""""""""""""""""""""""" " => Visual mode related """""""""""""""""""""""""""""" " Visual mode pressing * or # searches for the current selection " Super useful! From an idea by Michael Naumann vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR> vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR> " Return to last edit position when opening files (You want this!) au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif """""""""""""""""""""""""""""" " => Status line """""""""""""""""""""""""""""" " Always show the status line set laststatus=2 " Format the status line set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Spell checking """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Pressing ,ss will toggle and untoggle spell checking map <leader>ss :setlocal spell!<cr> " Quickly open a buffer for scribble map <leader>q :e ~/buffer<cr> " Quickly open a markdown buffer for scribble map <leader>x :e ~/buffer.md<cr> " TODO learn buffers " Don't close window, when deleting a buffer command! Bclose call <SID>BufcloseCloseIt() function! <SID>BufcloseCloseIt() let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") if buflisted(l:alternateBufNum) buffer # else bnext endif if bufnr("%") == l:currentBufNum new endif if buflisted(l:currentBufNum) execute("bdelete! ".l:currentBufNum) endif endfunction