1 " Global encoding setup 2 set encoding = utf -8 3 set fileencoding = utf -8 4 5 filetype plugin on " Enable language dependant settings. 6 filetype indent on " Enable language dependant auto indentation. 7 syntax on " Enable syntaxical coloration. 8 9 set background = dark " Who use light background anyway ? 10 colorscheme desert " Makes use of the desert default solor scheme. 11 12 let mapleader = "," " Change Leader from '\' to ','. 13 let maplocalleader = ";" " Sets LocalLeader to ';'. 14 15 nnoremap < Leader >< : tabnew $MYVIMRC < CR > 16 nnoremap < Leader >> :source $MYVIMRC < CR > 17 18 " Helper function : creates a directory if not already present. 19 function ! SafeMkdir ( path ) 20 if ! isdirectory ( a : path ) 21 call mkdir ( a : path , "p" , 0700 ) 22 endif 23 endfunction 24 25 call SafeMkdir ( $HOME . "/.vim/swap" ) 26 set swapfile " Use recovery files. 27 set directory = $HOME /.vim/ swap // 28 29 call SafeMkdir ( $HOME . "/.vim/undo" ) 30 set undofile " Keep an undo file (persistent). 31 set undodir = $HOME /.vim/ undo // 32 33 set cursorline " Highlight current line 34 set relativenumber " Show lines numbre relative to the cursor position. 35 set scrolloff = 5 " Always keep cursor away from top/bottom 36 37 set lazyredraw " Redraw window only when usefull 38 set showcmd " Show command while typing. 39 set showmode " Show current mode. Void is 'Normal' mode. 40 41 set expandtab " Replace <Tab> by $shiftwidth spaces. 42 set shiftround " Round spaces to the nearest $shiftwidth multiple. 43 set softtabstop = 4 " One softtab is two space long. 44 set shiftwidth = 4 " One <Tab> is 4 spaces long. 45 set tabstop = 4 " One TAB appears to be 4 spaces. 46 set autoindent " Automatic code file indentation. 47 48 set ignorecase " Ignore case while searching for an expression. 49 set smartcase " Disable 'ignorecase' if a capital letter is typed. 50 set fileignorecase " Ignode case whil searching for a file. 51 52 set incsearch " Show search's result(s) while typing. 53 set hlsearch " Highlight search's result(s). 54 nohlsearch " Disable highlight at a buffer opening. 55 nnoremap < Leader >< Space > : nohlsearch < CR > 56 57 " Enable status line visibility 58 set laststatus = 2 59 set statusline = \ D:%{getcwd () } " Working directory 60 set statusline += \ F:% f " Current file 61 set statusline += \ S:% m " File's modification state 62 set statusline += \ R:% r " File's permissions 63 set statusline += \ T:% y " File's language type 64 set statusline += \ L:% l /%L " Current line vs lines number 65 set statusline += \ C:% v " Current column 66 set statusline += \ P:% p " Current percentage 67 68 nnoremap j gj 69 nnoremap k gk 70 71 nnoremap < Leader >= mfggVG = `fzz 72 73 nnoremap < Leader > t : tabnew < Space > 74 nnoremap < Leader > h : tabfirst < CR > 75 nnoremap < Leader > j : tabprevious < CR > 76 nnoremap < Leader > k :tabnext < CR > 77 nnoremap < Leader > l : tablast < CR > 78 79 nnoremap < LocalLeader > h :tabmove0 < CR > 80 nnoremap < LocalLeader > j : tabmove -< CR > 81 nnoremap < LocalLeader > k : tabmove +< CR > 82 nnoremap < LocalLeader > l : tabmove $ < CR > 83 84 tnoremap < silent > < esc > < C - \ >< C - n > 85 86 noremap gf : vertical wincmd f < CR > 87 noremap gF : wincmd f < CR > 88 89 " Delete trailing spaces on save 90 autocmd BufWritePre * %s /\s\+$/ / e 91 92 "Goes back to the last cursor position before leaving the buffer. 93 autocmd BufReadPost * 94 \ if line ( "'\"" ) > 1 && line ( "'\"" ) <= line ( "$" ) | 95 \ execute "normal! g`\"" | 96 \ endif 97 98 " Send current buffer to 'ix' pastebin 99 function ! Ix () 100 : w ! [ - z "$1" ] && curl - F 'f:1=<-' ix.io || ix < "$1" ; 101 endfunction 102 nnoremap < Leader > X : call Ix ()< CR >