mirror of
https://github.com/hcartiaux/dotfiles.git
synced 2024-10-18 17:25:23 +02:00
250 lines
5.8 KiB
VimL
Executable file
250 lines
5.8 KiB
VimL
Executable file
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
"
|
|
" .bashrc -- my personal VIM configuration
|
|
" see https://github.com/hcartiaux/dotfiles
|
|
"
|
|
" Copyright (c) 2013 Hyacinthe Cartiaux <Hyacinthe.Cartiaux@uni.lu>
|
|
" _
|
|
" __ _(_)_ __ ___ _ __ ___
|
|
" \ \ / / | '_ ` _ \| '__/ __|
|
|
" \ V /| | | | | | | | | (__
|
|
" (_)_/ |_|_| |_| |_|_| \___|
|
|
"
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Resources:
|
|
" * https://github.com/Falkor/dotfiles/blob/master/vim/.vimrc
|
|
" * 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/
|
|
" * https://stackoverflow.com/questions/6496778/vim-run-autocmd-on-all-filetypes-except
|
|
" * http://vim.wikia.com/wiki/Omni_completion
|
|
" * http://amix.dk/vim/vimrc.html
|
|
|
|
set nocompatible
|
|
|
|
""""""""""""
|
|
" => General
|
|
""""""""""""
|
|
|
|
set history=1000
|
|
filetype on
|
|
filetype plugin on
|
|
filetype indent on
|
|
|
|
" Set to auto read when a file is changed from the outside
|
|
set autoread
|
|
|
|
" Fast saving
|
|
nmap <leader>w :w!<cr>
|
|
|
|
""""""""""""""""""""""""
|
|
" => 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
|
|
set ruler
|
|
|
|
" 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
|
|
set hlsearch
|
|
|
|
" 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
|
|
set scrolloff=1
|
|
|
|
" Try to preserve column where cursor is positioned during motion commands
|
|
set nostartofline
|
|
|
|
" Displaying status line always
|
|
set laststatus=2
|
|
|
|
" Set the status line format
|
|
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)
|
|
|
|
|
|
" Show information about the current command going on
|
|
set showcmd
|
|
|
|
|
|
""""""""""""""""""""""
|
|
" => Colors and Fonts
|
|
""""""""""""""""""""""
|
|
colorscheme default
|
|
set background=dark
|
|
|
|
" Set utf8 as standard encoding
|
|
set encoding=utf-8
|
|
set fileencoding=utf-8
|
|
set fileencodings=utf-8
|
|
|
|
" Use Unix as the standard file type
|
|
set ffs=unix,dos,mac
|
|
|
|
" Enable syntax highlighting
|
|
syntax enable
|
|
|
|
set cursorline
|
|
hi CursorLine term=bold cterm=bold ctermbg=blue ctermfg=white
|
|
|
|
" Custom cursor color in konsole, red in visualization mode, green in insert mode
|
|
if $XDG_CURRENT_DESKTOP == "KDE"
|
|
autocmd VimEnter * silent !konsoleprofile UseCustomCursorColor=true;BlinkingCursorEnabled=0 && clear
|
|
let &t_SI = "\<Esc>]50;CustomCursorColor=orange;BlinkingCursorEnabled=1\x7"
|
|
let &t_EI = "\<Esc>]50;CustomCursorColor=red;BlinkingCursorEnabled=0\x7"
|
|
silent !konsoleprofile CustomCursorColor=red
|
|
autocmd VimLeave * silent !konsoleprofile CustomCursorColor=false;BlinkingCursorEnabled=0
|
|
endif
|
|
|
|
" 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
|
|
|
|
if &term =~ '256color'
|
|
set t_ut=
|
|
endif
|
|
|
|
"""""""""""""""""""""""""""""
|
|
" => Files, backups and undo
|
|
"""""""""""""""""""""""""""""
|
|
|
|
" Centralize backups, swapfiles and undo history
|
|
set backup
|
|
set backupdir=$HOME/.vim/backup//
|
|
set directory=$HOME/.vim/swap//
|
|
|
|
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")
|
|
set undodir=$HOME/.vim/undo//
|
|
endif
|
|
end
|
|
|
|
set viminfo+=n$HOME/.vim/.viminfo
|
|
|
|
""""""""""""""""""""""""""""""""""
|
|
" => Text, tab and indent related
|
|
""""""""""""""""""""""""""""""""""
|
|
|
|
" Indent
|
|
set cindent
|
|
|
|
" Use spaces instead of tabs
|
|
set expandtab
|
|
|
|
" Be smart when using tabs ;)
|
|
set smarttab
|
|
|
|
" 1 tab = 2 spaces
|
|
set shiftwidth=2
|
|
set softtabstop=2
|
|
set tabstop=2
|
|
|
|
" Use tab when editing Makefiles
|
|
autocmd FileType make set noexpandtab
|
|
|
|
" Linebreak on 500 characters
|
|
set lbr
|
|
set textwidth=200
|
|
|
|
"" Use modeline overrides (file specific configuration)
|
|
set modeline
|
|
set modelines=10
|
|
|
|
"""""""""""""
|
|
" => Helpers
|
|
"""""""""""""
|
|
|
|
" Vim 7 spell checker (z=)
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
" Automatic headers
|
|
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
|
|
|
|
" Display trailing white spaces
|
|
set list listchars=tab:\ \ ,trail:·
|
|
" 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
|
|
|
|
" Shortcuts
|
|
map <F3> <Esc>:tabnext<CR>
|
|
map <F2> <Esc>:tabprevious<CR>
|
|
map <F4> <Esc>:set paste<CR>
|
|
|