Skip to content

Instantly share code, notes, and snippets.

@guelau
Last active August 29, 2015 14:08
Show Gist options
  • Save guelau/d2b6ccc2c5bb3dd0fdbc to your computer and use it in GitHub Desktop.
Save guelau/d2b6ccc2c5bb3dd0fdbc to your computer and use it in GitHub Desktop.
My personal vimrc
"""""""""""""""""""""""""""""""""""""
" GENERAL
"""""""""""""""""""""""""""""""""""""
set nocompatible
set history=500
" undo, pour revenir en arrière
set undolevels=150
" vim monitor realtime changes to a file
set autoread
"""""""""""""""""""""""""""""""""""""
" FILE
"""""""""""""""""""""""""""""""""""""
" Using multi-byte UTF-8 encoding
scriptencoding utf-8
set encoding=utf-8
" File type = Unix
set ffs=unix,dos,mac
set nostartofline
set backspace=indent,eol,start
set backup
" Backup dans ~/.vim/backup
if filewritable(expand("~/.vim/backup")) == 2
set backupdir=$HOME/.vim/backup
else
if has("unix") || has("win32unix")
call system("mkdir $HOME/.vim/backup -p")
set backupdir=$HOME/.vim/backup
endif
endif
if has("syntax")
syntax on
endif
"""""""""""""""""""""""""""""""""""""
" TAB AND INDENT
"""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
set smarttab
" tab = 4 spaces
set tabstop=4
set shiftwidth=4
" always set autoindenting on
set autoindent
" smart indent
set smartindent
" set cindent
set noautoindent
"set nosmartindent
set nocindent
"""""""""""""""""""""""""""""""""""""
" DISPLAY
"""""""""""""""""""""""""""""""""""""
" No sound and visual errors
set errorbells
set novisualbell
set t_vb=
set tm=500
" Show matching brackets when text indicator is over them
set showmatch
" How many seconds showing the matching brackets
"set matchtime=2
" status bar
set laststatus=2
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
" Format
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
" Show current position
set ruler
colorscheme desert
set background=dark
" Set extra options when running in GUI mode
"if has("gui_running")
set guioptions-=T
set guioptions+=e
set t_Co=256
set guitablabel=%M\ %t
"endif
" Highlighting the line where is the cursor
function s:SetCursorLine()
set cursorline
" show line numbers
set number
highlight CursorLine cterm=NONE ctermbg=DarkBlue ctermfg=LightYellow guibg=DarkBlue guifg=white
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
endfunction
"set cursorline
autocmd VimEnter * call s:SetCursorLine()
" Height of the command bar
set cmdheight=2
"""""""""""""""""""""""""""""""""""""
" SEARCHING
"""""""""""""""""""""""""""""""""""""
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
set scrolloff=3
set showcmd
set ttyfast
" For regular expressions turn magic on
set magic
"""""""""""""""""""""""""""""""""""""
" LEADER
"""""""""""""""""""""""""""""""""""""
" Set a map leader
" eq. <leader>w saves the current file
let mapleader = ";"
let g:mapleader = ";"
" Fast saving
nmap <leader>w :w!<cr>
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
"""""""""""""""""""""""""""""""""""""
" BUFFER AND TABS
"""""""""""""""""""""""""""""""""""""
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
map <space> /
map <c-space> ?
" Close the current buffer
map <leader>bd :Bclose<cr>
"""""""""""""""""""""""""""""""""""""
" DEVELOPER OPTIONS
"""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
if has("autocmd")
"au filetype html set omnifunc=htmlcomplete#CompleteTags
"au filetype css set omnifunc=csscomplete#CompleteCSS
"au filetype javascript set omnifunc=javascriptcomplete#CompleteJS
"au filetype php set omnifunc=phpcomplete#CompletePHP
"au filetype xml set omnifunc=xmlcomplete#CompleteTags
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
au FileType helpfile set nonumber " no line numbers when viewing help
au FileType helpfile nnoremap <buffer><cr> <c-]> " Enter selects subject
au FileType helpfile nnoremap <buffer><bs> <c-T> " Backspace to go back
au FileType mail,tex set textwidth=72
au FileType cpp,c,java,sh,pl,php,asp set autoindent
au FileType cpp,c,java,sh,pl,php,asp set smartindent
au FileType cpp,c,java,sh,pl,php,asp set cindent
au BufNewFile,BufRead *.pls set syntax=dosini
au BufNewFile,BufRead modprobe.conf set syntax=modconf
endif
@guelau
Copy link
Author

guelau commented Oct 23, 2014

Installation

mkdir ~/.config
git clone https://gist.github.com/d2b6ccc2c5bb3dd0fdbc.git ~/.config/vimrc
ln -sf ~/.config/vimrc ~/.vimrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment