2014-01-01 17:41:28 +01:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
"
|
|
|
|
" .bashrc -- my personal VIM configuration
|
|
|
|
" see https://github.com/hcartiaux/dotfiles
|
|
|
|
"
|
|
|
|
" Copyright (c) 2013 Hyacinthe Cartiaux <Hyacinthe.Cartiaux@uni.lu>
|
|
|
|
" _
|
|
|
|
" __ _(_)_ __ ___ _ __ ___
|
|
|
|
" \ \ / / | '_ ` _ \| '__/ __|
|
|
|
|
" \ V /| | | | | | | | | (__
|
|
|
|
" (_)_/ |_|_| |_| |_|_| \___|
|
|
|
|
"
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Resources:
|
2016-03-10 19:00:12 +01:00
|
|
|
" * https://github.com/Falkor/dotfiles/blob/master/vim/.vimrc
|
2014-01-01 17:41:28 +01:00
|
|
|
" * https://github.com/shingara/vim-conf/blob/master/vimrc
|
|
|
|
" * http://vim.wikia.com/wiki/Configuring_the_cursor
|
|
|
|
" * http://ftp.vim.org/pub/vim/runtime/spell/
|
2016-03-10 19:00:12 +01:00
|
|
|
" * https://stackoverflow.com/questions/6496778/vim-run-autocmd-on-all-filetypes-except
|
2014-01-01 17:41:28 +01:00
|
|
|
" * http://vim.wikia.com/wiki/Omni_completion
|
2014-01-06 23:18:56 +01:00
|
|
|
" * http://amix.dk/vim/vimrc.html
|
|
|
|
|
|
|
|
set nocompatible
|
|
|
|
|
|
|
|
""""""""""""
|
|
|
|
" => General
|
|
|
|
""""""""""""
|
|
|
|
|
|
|
|
set history=1000
|
2013-05-02 23:39:27 +02:00
|
|
|
filetype on
|
2014-01-06 23:18:56 +01:00
|
|
|
filetype plugin on
|
|
|
|
filetype indent on
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
" Set to auto read when a file is changed from the outside
|
|
|
|
set autoread
|
|
|
|
|
2016-03-11 15:21:11 +01:00
|
|
|
"" Map leader to ,
|
|
|
|
let mapleader=','
|
2014-01-06 23:18:56 +01:00
|
|
|
|
|
|
|
""""""""""""""""""""""""
|
|
|
|
" => VIM user interface
|
|
|
|
""""""""""""""""""""""""
|
|
|
|
|
|
|
|
" Turn on the WiLd menu
|
|
|
|
set wildmenu
|
|
|
|
set wildmode=list:longest,full
|
|
|
|
|
|
|
|
" Ignore compiled files
|
|
|
|
set wildignore=*.o,*~,*.pyc,*.obj,.git,*.rbc
|
|
|
|
|
|
|
|
" Use the mouse
|
|
|
|
set mouse=a
|
|
|
|
|
|
|
|
" Always show current position
|
2013-07-26 11:22:22 +02:00
|
|
|
set ruler
|
2014-01-06 23:18:56 +01:00
|
|
|
|
|
|
|
" A buffer becomes hidden when it is abandoned
|
|
|
|
set hid
|
|
|
|
|
|
|
|
" Show line numbers
|
|
|
|
" set number
|
|
|
|
|
|
|
|
" 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
|
|
|
|
|
|
|
|
" Highlight search results
|
2013-05-02 23:39:27 +02:00
|
|
|
set hlsearch
|
2014-01-06 23:18:56 +01:00
|
|
|
|
|
|
|
" Makes search act like search in modern browsers
|
|
|
|
set incsearch
|
|
|
|
|
|
|
|
" Don't redraw while executing macros (good performance config)
|
|
|
|
set lazyredraw
|
|
|
|
|
|
|
|
" For regular expressions turn magic on
|
|
|
|
set magic
|
|
|
|
|
|
|
|
" 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
|
|
|
|
|
|
|
|
" No annoying sound on errors
|
|
|
|
set noerrorbells
|
|
|
|
set novisualbell
|
|
|
|
set t_vb=
|
|
|
|
set tm=500
|
|
|
|
|
|
|
|
" Keep 1 line when scrolling
|
2013-05-02 23:39:27 +02:00
|
|
|
set scrolloff=1
|
2014-01-06 23:18:56 +01:00
|
|
|
|
|
|
|
" Try to preserve column where cursor is positioned during motion commands
|
2013-05-02 23:39:27 +02:00
|
|
|
set nostartofline
|
2014-01-06 23:18:56 +01:00
|
|
|
|
|
|
|
" Displaying status line always
|
2013-07-26 11:22:22 +02:00
|
|
|
set laststatus=2
|
2014-01-06 23:18:56 +01:00
|
|
|
|
2016-03-10 18:48:03 +01:00
|
|
|
" Set the status line format
|
|
|
|
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)
|
|
|
|
|
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
" Show information about the current command going on
|
2013-07-26 11:22:22 +02:00
|
|
|
set showcmd
|
2014-01-01 17:41:28 +01:00
|
|
|
|
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
""""""""""""""""""""""
|
|
|
|
" => Colors and Fonts
|
|
|
|
""""""""""""""""""""""
|
|
|
|
colorscheme default
|
2015-03-26 11:54:56 +01:00
|
|
|
set background=dark
|
2014-01-01 17:41:28 +01:00
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
" Set utf8 as standard encoding
|
|
|
|
set encoding=utf-8
|
|
|
|
set fileencoding=utf-8
|
2016-03-10 18:48:03 +01:00
|
|
|
set fileencodings=utf-8
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
" Use Unix as the standard file type
|
|
|
|
set ffs=unix,dos,mac
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
" Enable syntax highlighting
|
|
|
|
syntax enable
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
set cursorline
|
|
|
|
hi CursorLine term=bold cterm=bold ctermbg=blue ctermfg=white
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2016-03-10 18:45:59 +01:00
|
|
|
" Custom cursor color in konsole, red in visualization mode, green in insert mode
|
2014-01-06 23:18:56 +01:00
|
|
|
if $XDG_CURRENT_DESKTOP == "KDE"
|
2016-03-10 18:45:59 +01:00
|
|
|
autocmd VimEnter * silent !konsoleprofile UseCustomCursorColor=true;BlinkingCursorEnabled=0 && clear
|
2014-01-06 23:18:56 +01:00
|
|
|
let &t_SI = "\<Esc>]50;CustomCursorColor=orange;BlinkingCursorEnabled=1\x7"
|
|
|
|
let &t_EI = "\<Esc>]50;CustomCursorColor=red;BlinkingCursorEnabled=0\x7"
|
|
|
|
silent !konsoleprofile CustomCursorColor=red
|
2016-03-10 18:45:59 +01:00
|
|
|
autocmd VimLeave * silent !konsoleprofile CustomCursorColor=false;BlinkingCursorEnabled=0
|
2014-01-06 23:18:56 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
" Set extra options when running in GUI mode
|
|
|
|
if has("gui_running")
|
2016-03-10 18:48:03 +01:00
|
|
|
set guioptions-=T
|
|
|
|
set guioptions+=e
|
|
|
|
set t_Co=256
|
|
|
|
set guitablabel=%M\ %t
|
2014-01-06 23:18:56 +01:00
|
|
|
endif
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2016-03-10 18:48:03 +01:00
|
|
|
if &term =~ '256color'
|
|
|
|
set t_ut=
|
|
|
|
endif
|
2014-01-06 23:18:56 +01:00
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""
|
|
|
|
" => Files, backups and undo
|
|
|
|
"""""""""""""""""""""""""""""
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2013-05-03 02:54:00 +02:00
|
|
|
" Centralize backups, swapfiles and undo history
|
2013-05-02 23:39:27 +02:00
|
|
|
set backup
|
2015-03-06 15:03:10 +01:00
|
|
|
set backupdir=$HOME/.vim/backup//
|
|
|
|
set directory=$HOME/.vim/swap//
|
2015-03-06 11:13:20 +01:00
|
|
|
|
2015-03-26 11:53:13 +01:00
|
|
|
if has('persistent_undo')
|
|
|
|
set undofile
|
|
|
|
set undolevels=1000 "maximum number of changes that can be undone
|
|
|
|
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
|
|
|
|
if exists("&undodir")
|
2015-03-06 15:03:10 +01:00
|
|
|
set undodir=$HOME/.vim/undo//
|
2015-03-26 11:53:13 +01:00
|
|
|
endif
|
|
|
|
end
|
2015-03-06 11:13:20 +01:00
|
|
|
|
2013-05-03 02:54:00 +02:00
|
|
|
set viminfo+=n$HOME/.vim/.viminfo
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
""""""""""""""""""""""""""""""""""
|
|
|
|
" => Text, tab and indent related
|
|
|
|
""""""""""""""""""""""""""""""""""
|
|
|
|
|
|
|
|
" Indent
|
|
|
|
set cindent
|
|
|
|
|
|
|
|
" Use spaces instead of tabs
|
|
|
|
set expandtab
|
|
|
|
|
|
|
|
" Be smart when using tabs ;)
|
|
|
|
set smarttab
|
|
|
|
|
2016-03-11 15:19:55 +01:00
|
|
|
" 1 tab = 4 spaces
|
|
|
|
set shiftwidth=4
|
|
|
|
set softtabstop=4
|
|
|
|
set tabstop=4
|
2014-01-06 23:18:56 +01:00
|
|
|
|
2015-04-02 10:43:04 +02:00
|
|
|
" Use tab when editing Makefiles
|
|
|
|
autocmd FileType make set noexpandtab
|
2014-01-06 23:18:56 +01:00
|
|
|
|
2016-11-17 10:54:18 +01:00
|
|
|
" Linebreak on 200 characters
|
|
|
|
" set lbr
|
|
|
|
" set textwidth=200
|
2014-01-06 23:18:56 +01:00
|
|
|
|
2016-03-10 18:48:03 +01:00
|
|
|
"" Use modeline overrides (file specific configuration)
|
|
|
|
set modeline
|
|
|
|
set modelines=10
|
2014-01-06 23:18:56 +01:00
|
|
|
|
|
|
|
"""""""""""""
|
|
|
|
" => Helpers
|
|
|
|
"""""""""""""
|
|
|
|
|
2013-05-02 23:39:27 +02:00
|
|
|
" Vim 7 spell checker (z=)
|
|
|
|
if has("spell")
|
|
|
|
setlocal spell spelllang=
|
|
|
|
" Language : FR
|
2016-03-11 15:21:11 +01:00
|
|
|
map <Leader>lf :setlocal spell spelllang=fr<cr>
|
2013-05-02 23:39:27 +02:00
|
|
|
" Language : EN
|
2016-03-11 15:21:11 +01:00
|
|
|
map <Leader>le :setlocal spell spelllang=en<cr>
|
2013-05-02 23:39:27 +02:00
|
|
|
" Language : Aucun
|
2016-03-11 15:21:11 +01:00
|
|
|
map <Leader>ln :setlocal spell spelllang=<cr>
|
2013-05-02 23:39:27 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
set spellsuggest=5
|
|
|
|
autocmd BufEnter *.txt,*.tex,*.md set spell
|
|
|
|
autocmd BufEnter *.txt,*.tex set spelllang=fr
|
|
|
|
autocmd BufEnter *.md set spelllang=en
|
|
|
|
autocmd BufNewFile,BufRead PKGBUILD set syntax=sh
|
|
|
|
|
2014-01-06 23:18:56 +01:00
|
|
|
|
|
|
|
" Automatic headers
|
2013-05-02 23:39:27 +02:00
|
|
|
autocmd bufnewfile *.rb so ~/.vim/header/ruby
|
|
|
|
autocmd bufnewfile *.pl so ~/.vim/header/perl
|
|
|
|
autocmd bufnewfile *.sh so ~/.vim/header/shell
|
|
|
|
au BufRead,BufNewFile *.md set syntax=markdown
|
|
|
|
|
2013-06-13 17:04:48 +02:00
|
|
|
" Display trailing white spaces
|
2013-05-02 23:39:27 +02:00
|
|
|
set list listchars=tab:\ \ ,trail:·
|
2013-06-13 17:04:48 +02:00
|
|
|
" Remove trailing white spaces in all files except *.md
|
|
|
|
fun! StripTrailingWhitespace()
|
|
|
|
" Only strip if the b:noStripeWhitespace variable isn't set
|
|
|
|
if exists('b:noStripWhitespace')
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
%s/\s\+$//e
|
|
|
|
endfun
|
|
|
|
autocmd BufWritePre * call StripTrailingWhitespace()
|
|
|
|
autocmd FileType markdown let b:noStripWhitespace=1
|
2013-05-02 23:39:27 +02:00
|
|
|
|
2016-11-17 10:54:41 +01:00
|
|
|
"===========================================================================
|
|
|
|
"" File explorer panel config
|
|
|
|
"===========================================================================
|
|
|
|
" https://shapeshed.com/vim-netrw/
|
|
|
|
|
|
|
|
let g:netrw_banner = 0
|
|
|
|
let g:netrw_liststyle = 3
|
|
|
|
let g:netrw_browse_split = 4
|
|
|
|
let g:netrw_altv = 1
|
|
|
|
let g:netrw_winsize = 25
|
|
|
|
let g:netrw_banner = 0
|
|
|
|
|
2016-03-11 15:21:11 +01:00
|
|
|
"===========================================================================
|
|
|
|
"" Mappings
|
|
|
|
"===========================================================================
|
|
|
|
|
|
|
|
map <F4> <Esc>:set paste<CR>
|
|
|
|
|
2016-11-17 10:55:44 +01:00
|
|
|
"" Split
|
|
|
|
noremap <Leader>h :<C-u>split<CR>
|
|
|
|
noremap <Leader>v :<C-u>vsplit<CR>
|
|
|
|
|
|
|
|
"" Tabs
|
|
|
|
nnoremap <Tab> gt
|
|
|
|
nnoremap <S-Tab> gT
|
|
|
|
nnoremap <silent> <S-t> :tabnew<CR>
|
2013-07-26 11:22:22 +02:00
|
|
|
map <F3> <Esc>:tabnext<CR>
|
|
|
|
map <F2> <Esc>:tabprevious<CR>
|
2016-03-11 15:21:11 +01:00
|
|
|
|
|
|
|
"" Copy/Paste/Cut
|
|
|
|
if has('unnamedplus')
|
|
|
|
set clipboard=unnamed,unnamedplus
|
|
|
|
endif
|
2014-01-06 23:18:56 +01:00
|
|
|
|
2016-11-17 10:55:44 +01:00
|
|
|
noremap YY "+y<CR>
|
|
|
|
noremap <leader>p "+gP<CR>
|
|
|
|
noremap XX "+x<CR>
|
|
|
|
|
|
|
|
"" Buffer nav
|
|
|
|
noremap <leader>q :bp<CR>
|
|
|
|
noremap <leader>s :bn<CR>
|
|
|
|
|
|
|
|
"" Close buffer
|
|
|
|
noremap <leader>c :bd<CR>
|
|
|
|
|
|
|
|
"" Clean search (highlight)
|
|
|
|
nnoremap <silent> <leader><space> :noh<cr>
|
|
|
|
|
|
|
|
"" Vmap for maintain Visual Mode after shifting > and <
|
|
|
|
vmap < <gv
|
|
|
|
vmap > >gv
|
|
|
|
|
|
|
|
"" Move visual block
|
|
|
|
vnoremap J :m '>+1<CR>gv=gv
|
|
|
|
vnoremap K :m '<-2<CR>gv=gv
|
|
|
|
|
|
|
|
|