Created
June 16, 2011 23:48
-
-
Save fxthomas/1030584 to your computer and use it in GitHub Desktop.
VimRC
This file contains hidden or 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
" Basic Settings | |
set nocompatible | |
syntax on | |
set ofu=syntaxcomplete#Complete | |
set autoread " If an open file is changed outside of VIM, it is automatically reloaded | |
filetype on | |
filetype plugin on | |
filetype plugin indent on | |
set number | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
set wildmenu | |
set backspace=indent,eol,start " backspace erases in insert mode | |
set backup | |
set history=100 " reasonable history | |
set ruler " show line/character in statusbar | |
set showcmd " show number of lines selected in visual | |
set nowrap " wrap lines automatically (create new | |
map <C-S> :w<CR> | |
set number " show line numbers | |
" Clojure REPL | |
let vimclojure#WantNailgun = 1 | |
let vimclojure#NailgunClient = "ng" | |
" Backup in ~/.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 | |
" Break comment lines but not at middle of words | |
set formatoptions=l | |
set lbr | |
" Appearance | |
colorscheme lettuce | |
" Use 256 color palette if available | |
if &term=="xterm" | |
set t_Co=256 | |
endif | |
" Highlight searches, searches begin immediately | |
set hlsearch | |
set incsearch | |
" Non-case-sensitive searches | |
set ignorecase | |
set smartcase | |
set infercase | |
" Tab settings | |
set tabstop=2 " tab character amount | |
set expandtab " tabs as space | |
set smartindent " smart autoindenting on a new line | |
set shiftwidth=2 " set spaces for autoindent | |
set softtabstop=2 | |
" Folding | |
set foldcolumn=1 | |
set foldmethod=syntax | |
set foldlevelstart=99 | |
" Navigation | |
set nostartofline " navigate closest column | |
set showtabline=2 " tab bar always on | |
"set showmatch " bouncy parenthesis | |
" Visual bells give me seizures | |
set t_vb='' | |
" Mouse support (cursor position, tab selection - hold shift to select | |
" n = normal mode, i = insert, c = command, a = all | |
set mouse=ni | |
" Setting menu tab completion | |
set wildignore+=*.o,*~,.lo | |
set wildignore+=.jpg,.png,.jpeg,.gif,~,.swp,.swo,.info,.o,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.pyc,.pyo | |
set suffixes+=.in,.a | |
" Vim 7 spell checker | |
if has("spell") | |
setlocal spell spelllang= | |
" Language : FR | |
map ,lf :setlocal spell spelllang=fr<cr> | |
" Language : EN | |
map ,le :setlocal spell spelllang=en<cr> | |
" Language : Aucun | |
map ,ln :setlocal spell spelllang=<cr> | |
endif | |
" Key mappings | |
set pastetoggle=<F3> " disable autoindent when pasting | |
imap <F4> <Esc> " easier to reach Esc | |
nn <F5> :setlocal spell! spell?<CR> " spelling toggle | |
map <C-l> <Esc>z= " spellcheck suggestions | |
map <F7> <Esc>:set mouse=<CR> " mouse support off | |
map <F8> <Esc>:set mouse=ni<CR> " mouse support on | |
vmap <F9> :w !xclip -f -sel clip<CR> " copy text to xorg server | |
vmap <C-c> :w !xclip -f -sel clip<CR> " copy using regular shortcuts | |
map <F10> :-1r !xclip -o -sel clip<CR> " paste text from xserv clip to | |
" past text using regular shortcuts | |
imap <C-v> <Esc>:-1r !xclip -o -sel clip<CR>i | |
map <CR> o<Esc> " newline with Enter | |
noremap <C-J> gj " wrapped line navigation | |
noremap <C-K> gk | |
noremap <C-M> :!make<CR> | |
map ,t :tabnew<CR> | |
map <C-j> :%w !~/Scripts/jsonv<CR> | |
" Tab navigation like Firefox | |
nmap <C-S-tab> :tabprevious<CR> | |
nmap <C-tab> :tabnext<CR> | |
map <C-S-tab> :tabprevious<CR> | |
map <C-tab> :tabnext<CR> | |
imap <C-S-tab> <Esc>:tabprevious<CR>i | |
imap <C-tab> <Esc>:tabnext<CR>i | |
nmap <C-t> :tabnew<CR> | |
imap <C-t> <Esc>:tabnew<CR> | |
if has("gui_running") | |
" If the current buffer has never been saved, it will have no name, | |
" " call the file browser to save it, otherwise just save it. | |
" :map <silent> <C-S> :if expand("%") == ""<CR>:browse confirm | |
"w<CR>:else<CR>:confirm w<CR>:endif<CR> | |
endif | |
" Space bar un-highligts search | |
:noremap <silent> <Space> :silent noh<Bar>echo<CR> | |
" Auto template commands | |
"HTML Pages | |
au bufNewFile *.html 0r ~/.vim/templates/html | |
au bufNewFile *.html silent exe "%s/%PLACE_CURSOR%//" | |
au bufNewFile *.htm 0r ~/.vim/templates/html | |
au bufNewFile *.htm silent exe "%s/%PLACE_CURSOR%//" | |
"PHP Scripts | |
au bufNewFile *.php 0r ~/.vim/templates/php | |
au bufNewFile *.php silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.php silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.php silent exe "%s/%PLACE_CURSOR%//" | |
"CSS Stylesheets | |
au bufNewFile *.css 0r ~/.vim/templates/css | |
au bufNewFile *.css silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.css silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.css silent exe "%s/%PLACE_CURSOR%//" | |
"Bash scripts | |
au bufNewFile *.sh 0r ~/.vim/templates/bash | |
au bufNewFile *.sh silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.sh silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.sh silent exe "%s/%PLACE_CURSOR%//" | |
"Python Scripts | |
au bufNewFile *.py 0r ~/.vim/templates/python | |
au bufNewFile *.py silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.py silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.py silent exe "%s/%PLACE_CURSOR%//" | |
"Python2 Scripts | |
au bufNewFile *.py2 0r ~/.vim/templates/python2 | |
au bufNewFile *.py2 silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.py2 silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.py2 silent exe "%s/%PLACE_CURSOR%//" | |
"C++ Source files | |
au bufNewFile *.cpp 0r ~/.vim/templates/cpp | |
au bufNewFile *.cpp silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.cpp silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.cpp silent exe "%s/%PLACE_FILENOEXT%/".substitute(expand("%"), ".cpp$", "", "g")."/g" | |
au bufNewFile *.cpp silent exe "%s/%PLACE_CURSOR%//" | |
"C++ Headers | |
au bufNewFile *.hpp 0r ~/.vim/templates/hpp | |
au bufNewFile *.hpp silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.hpp silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.hpp silent exe "%s/%PLACE_FILENOEXT%/".substitute(expand("%"), ".hpp$", "", "g")."/g" | |
au bufNewFile *.hpp silent exe "%s/%PLACE_CURSOR%//" | |
"C Source files | |
au bufNewFile *.c 0r ~/.vim/templates/c | |
au bufNewFile *.c silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.c silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.c silent exe "%s/%PLACE_CURSOR%//" | |
"C Headers | |
au bufNewFile *.h 0r ~/.vim/templates/h | |
au bufNewFile *.h silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.h silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.h silent exe "%s/%PLACE_CURSOR%//" | |
"Java source code | |
au bufNewFile *.java 0r ~/.vim/templates/java | |
au bufNewFile *.java silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.java silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.java silent exe "%s/%PLACE_FILENOEXT%/".substitute(expand("%"), ".java$", "", "g")."/g" | |
au bufNewFile *.java silent exe "%s/%PLACE_CURSOR%//" | |
"C for CUDA source code | |
au bufNewFile *.cu 0r ~/.vim/templates/cu | |
au bufNewFile *.cu silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.cu silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.cu silent exe "%s/%PLACE_CURSOR%//" | |
"Ninja Build Script | |
au bufNewFile *.ninja 0r ~/.vim/templates/ninja | |
au bufNewFile *.ninja silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.ninja silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.ninja silent exe "%s/%PLACE_CURSOR%//" | |
"JavaScript | |
au bufNewFile *.js 0r ~/.vim/templates/js | |
au bufNewFile *.js silent exe "%s/%PLACE_FILENAME%/".expand("%")."/g" | |
au bufNewFile *.js silent exe "%s/%PLACE_CREATETIME%/".strftime("%c")."/g" | |
au bufNewFile *.js silent exe "%s/%PLACE_CURSOR%//" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment