Skip to content

Instantly share code, notes, and snippets.

@apraga
Created November 30, 2012 10:09
Show Gist options
  • Save apraga/4174919 to your computer and use it in GitHub Desktop.
Save apraga/4174919 to your computer and use it in GitHub Desktop.
Vim config
" Do you want bepo configuration ? 0 if not
let want_bepo = 1
" Set 'nocompatible' to ward off unexpected things that your distro might
" have made, as well as sanely reset options when re-sourcing .vimrc
set nocompatible
" Attempt to determine the type of a file based on its name and possibly its
" contents. Use this to allow intelligent auto-indenting for each filetype,
" and for plugins that are filetype specific.
filetype indent plugin on
" Enable syntax highlighting
syntax on
"------------------------------------------------------------
" Allows you to switch from an
" unsaved buffer without saving it first. Also allows you to keep an undo
" history for multiple files. Vim will complain if you try to quit without
" saving, and swap files will keep you safe if your computer crashes.
set hidden
" Better command-line completion
set wildmenu
" Show partial commands in the last line of the screen
set showcmd
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the
" mapping of <C-L> below)
set hlsearch
"------------------------------------------------------------
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
" Always display the status line, even if only one window is displayed
set laststatus=2
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
" Use visual bell instead of beeping when doing something wrong
set visualbell
" And reset the terminal code for the visual bell. If visualbell is set, and
" this line is also included, vim will neither flash nor beep. If visualbell
" is unset, this does nothing.
set t_vb=
" Deactivate vim mouse
set mouse=
" Set the command window height to 2 lines, to avoid many cases of having to
" "press <Enter> to continue"
set cmdheight=2
" Display line numbers on the left
set number
" Quickly time out on keycodes, but never time out on mappings
set notimeout ttimeout ttimeoutlen=200
" Text width
set tw=80
"------------------------------------------------------------
" Indentation settings for using 2 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set shiftwidth=2
set softtabstop=2
set expandtab
"-----------------------------------------------------------
" Spell check
" set spell
" setlocal spell spelllang=en
"setlocal spell spelllang=fr
" Only for tex files
"augroup filetypedetect
" au BufNewFile,BufRead *.tex set spell
" au BufNewFile,BufRead *.tex setlocal spell spelllang=fr
"augroup END
"-----------------------------------------------------------
" Theme
"-----------------------------------------------------------
let moria_style = 'dark'
"Terminal colors
set t_Co=256
colorscheme moria
"-----------------------------------------------------------
" Remappings
"-----------------------------------------------------------
" Navigation for split windows
if (want_bepo)
nmap <silent> <S-up> :wincmd k<CR>
nmap <silent> <S-down> :wincmd j<CR>
nmap <silent> <S-left> :wincmd h<CR>
nmap <silent> <S-right> :wincmd l<CR>
endif
" Goes to function definition in new tab
if (want_bepo)
map <C-]> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
endif
"nmap <C-PageUp> :tabprevious<cr>
"nmap <C-PageDown> :tabnext<cr>
if $TERM =~ '^screen'
"map  <C-Left>
"map  <C-Right>
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif
nmap <C-Left> :tabprevious<cr>
nmap <C-Right> :tabnext<cr>
nmap <C-t> :tabnew<cr>
" Map <C-L> (redraw screen) to also turn off search highlighting until the
" next search
nnoremap <C-L> :nohl<CR><C-L>
" Replace a selection
vnoremap <C-h> "hy:%s/<C-r>h//gc<left><left><left>
" No search hilight
:noremap <silent> <c-l> :nohls<cr><c-l>
" Quick save
if (want_bepo)
noremap <Leader>s :update<CR>
endif
" Backspace behave as
map <Left><Del>
map! <Left><Del>
" Words count
map <F9> :w !detex \| wc -w<CR>
"-----------------------------------------------------------
" Plugins
"-----------------------------------------------------------
" Ctags
" Ctr P for fuzzy file searching
set runtimepath^=~/.vim/bundle/ctrlp.vim
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
" For git projects, we prefer to use a faster ls. Does not show untracked files
" though !
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files']
" Must set here the excluding rule, otherwise does not work with find
"let g:ctrlp_user_command = 'find %s -type f | grep -v -P "\.mod$|/tmp/"'
" Source code browser
map <F3> :TlistToggle<CR>
" With file exploring easier to start
map <F2> :Explore<CR>
" Search for selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
"-----------------------------------------------------------
" Config for languages
"-----------------------------------------------------------
" Fortran
let fortran_free_source=1
let fortran_do_enddo=1
" My own format
au BufRead,BufNewFile *.art syntax clear
" Config for Taglist
let Tlist_Sort_Type = "name"
"-----------------------------------------------------------
" Misc
"-----------------------------------------------------------
" Avoid trojan
set nomodeline
" Vim orgmode
au! BufRead,BufWrite,BufWritePost,BufNewFile *.org
au BufEnter *.org call org#SetOrgFileType()
":nmap <S-w> :call <SNR>24_ReplaceTodo()<CR>
" For Bepo
" [HJKL] -> {CTSR}
" ————————————————
" {cr} = « gauche / droite »
noremap c h
noremap r l
" {ts} = « haut / bas »
noremap t j
noremap s k
" {CR} = « haut / bas de l'écran »
noremap C H
noremap R L
" {TS} = « joindre / aide »
noremap T J
noremap S K
" Corollaire : repli suivant / précédent
noremap zs zj
noremap zt zk
" {HJKL} <- [CTSR]
" ————————————————
" {J} = « Jusqu'à » (j = suivant, J = précédant)
noremap j t
noremap J T
" {L} = « Change » (l = attend un mvt, L = jusqu'à la fin de
" ligne)
noremap l c
noremap L C
" {H} = « Remplace » (h = un caractère slt, H = reste en «
" Remplace »)
noremap h r
noremap H R
" {K} = « Substitue » (k = caractère, K = ligne)
noremap k s
noremap K S
" Corollaire : correction orthographique
noremap ]k ]s
noremap [k [s
" Desambiguation de {g}
" —————————————————————
" ligne écran précédente / suivante (à l'intérieur d'une phrase)
noremap gs gk
noremap gt gj
" onglet précédant / suivant
noremap gb gT
noremap gé gt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment