Created
March 20, 2017 17:50
-
-
Save marcolivierarsenault/222d8c80b5e20d767c7af04daee1b86a to your computer and use it in GitHub Desktop.
My own vimrc config file
This file contains 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Maintainer: | |
" Marc-Olivier Arsenault | |
" marcolivier.arsenault@gmail.com | |
" | |
" Version: | |
" 1.0 - 20/03/2017 | |
" | |
" Blog_post: | |
" Highly inspired from Awesome vim file | |
" http://amix.dk/blog/post/19691#The-ultimate-Vim-configuration-on-Github | |
" | |
" Awesome_version: | |
" Install the awesome version from: | |
" | |
" https://github.com/amix/vimrc | |
" | |
" Sections: | |
" -> General | |
" -> Folding | |
" -> Colors and Fonts | |
" -> Files and backups | |
" -> Text, tab and indent related | |
" -> Visual mode related | |
" -> Moving around, tabs and buffers | |
" -> Status line | |
" -> Editing mappings | |
" -> Misc | |
" -> Vundle and Plugins deff | |
" -> NERD Tree | |
" -> CtrlP | |
" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => General | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Sets how many lines of history VIM has to remember | |
set history=700 | |
" Enable filetype plugins | |
filetype plugin on | |
filetype indent on | |
" Set to auto read when a file is changed from the outside | |
set autoread | |
" With a map leader it's possible to do extra key combinations | |
" like <leader>w saves the current file | |
let mapleader = "," | |
let g:mapleader = "," | |
" Fast saving | |
nmap <leader>w :w!<cr> | |
" Show line number | |
set number | |
"show last command | |
set showcmd | |
" enable mouse support | |
set mouse=a | |
" Turn on the WiLd menu | |
set wildmenu | |
" Use Relative line number | |
set relativenumber | |
" Ignore compiled files | |
set wildignore=*.o,*~,*.pyc | |
"Always show current position | |
set ruler | |
" Height of the command bar | |
set cmdheight=1 | |
" A buffer becomes hidden when it is abandoned | |
set hid | |
" 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 | |
" Remove search hightlight | |
nnoremap <leader><space> :nohlsearch<CR> | |
" 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 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Folding | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set foldenable " enable folding | |
set foldlevelstart=10 " open most folds by default | |
set foldnestmax=10 " 10 nested fold max | |
nnoremap <space> za | |
set foldmethod=indent " fold based on indent level | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Colors and Fonts | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Enable syntax highlighting | |
syntax enable | |
colorscheme desert | |
set background=dark | |
set cursorline "Show cursor line in bold | |
hi CursorLine term=bold cterm=bold guibg=Grey40 | |
" 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 | |
" Set utf8 as standard encoding and en_US as the standard language | |
set encoding=utf8 | |
" Use Unix as the standard file type | |
set ffs=unix,dos,mac | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Files, backups and undo | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Turn backup off, since most stuff is in SVN, git et.c anyway... | |
set nobackup | |
set nowb | |
set noswapfile | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Text, tab and indent related | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Use spaces instead of tabs | |
set expandtab | |
" Be smart when using tabs ;) | |
set smarttab | |
" 1 tab == 4 spaces | |
set shiftwidth=4 | |
set tabstop=4 | |
" Linebreak on 500 characters | |
set lbr | |
set tw=500 | |
set ai "Auto indent | |
set si "Smart indent | |
set wrap "Wrap lines | |
"""""""""""""""""""""""""""""" | |
" => Visual mode related | |
"""""""""""""""""""""""""""""" | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
vnoremap <silent> * :call VisualSelection('f')<CR> | |
vnoremap <silent> # :call VisualSelection('b')<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Moving around, tabs, windows and buffers | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Treat long lines as break lines (useful when moving around in them) | |
map j gj | |
map k gk | |
" Disable highlight when <leader><cr> is pressed | |
map <silent> <leader><cr> :noh<cr> | |
" Smart way to move between windows | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
" Close the current buffer | |
map <leader>bd :Bclose<cr> | |
" Close all the buffers | |
map <leader :1,1000 bd!<cr> | |
" Useful mappings for managing tabs | |
map <leader>tn :tabnew<cr> | |
map <leader>to :tabonly<cr> | |
map <leader>tc :tabclose<cr> | |
map <leader>tm :tabmove | |
" Opens a new tab with the current buffer's path | |
" Super useful when editing files in the same directory | |
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/ | |
" Switch CWD to the directory of the open buffer | |
map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Specify the behavior when switching between buffers | |
try | |
set switchbuf=useopen,usetab,newtab | |
set stal=2 | |
catch | |
endtry | |
" Return to last edit position when opening files (You want this!) | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
" Remember info about open buffers on close | |
set viminfo^=% | |
"""""""""""""""""""""""""""""" | |
" => Status line | |
"""""""""""""""""""""""""""""" | |
" Always show the status line | |
set laststatus=2 | |
" Format the status line | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Editing mappings | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Move a line of text using CTR+[jk] | |
nnoremap <C-j> :m .+1<CR>== | |
nnoremap <C-k> :m .-2<CR>== | |
" Insert mode | |
inoremap <C-j> <ESC>:m .+1<CR>==gi | |
inoremap <C-k> <ESC>:m .-2<CR>==gi | |
" Visual mode | |
vnoremap <C-j> :m '>+1<CR>gv=gv | |
vnoremap <C-k> :m '<-2<CR>gv=gv | |
" Delete trailing white space on save, useful for Python and CoffeeScript ;) | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite *.py :call DeleteTrailingWS() | |
autocmd BufWrite *.coffee :call DeleteTrailingWS() | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Misc | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Remove the Windows ^M - when the encodings gets messed up | |
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm | |
" Quickly open a buffer for scripbble | |
map <leader>q :e ~/buffer<cr> | |
" Toggle paste mode on and off | |
map <leader>pp :setlocal paste!<cr> | |
" to work with TMUX | |
if exists('$TMUX') | |
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" | |
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" | |
else | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
endif | |
" Toggle relative line | |
function! NumberToggle() | |
if(&relativenumber == 1) | |
set norelativenumber | |
else | |
set relativenumber | |
endif | |
endfunc | |
nnoremap <C-n> :call NumberToggle()<cr> | |
function! CustomtoggleGui() | |
if(&number == 1) | |
set nonumber | |
set norelativenumber | |
NERDTreeClose | |
else | |
set number | |
set relativenumber | |
NERDTree | |
endif | |
endfunc | |
" Copy into real buffer | |
nnoremap <C-c> :call CustomtoggleGui()<cr> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => vundle and plugin | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set nocompatible " be iMproved, required | |
filetype off " required | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'ConradIrwin/vim-bracketed-paste' | |
Plugin 'scrooloose/nerdtree' | |
Bundle 'jistr/vim-nerdtree-tabs' | |
Plugin 'tpope/vim-fugitive' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'tpope/vim-surround' | |
Plugin 'bling/vim-airline' | |
Plugin 'airblade/vim-gitgutter' | |
Plugin 'kien/ctrlp.vim' | |
Plugin 'scrooloose/nerdcommenter' | |
call vundle#end() " required | |
filetype plugin indent on " required | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => NERD Tree | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:nerdtree_tabs_open_on_console_startup=1 | |
let NERDTreeShowHidden=1 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => CtrlP | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:ctrlp_map = '<C-t>' | |
let g:ctrlp_cmd = 'CtrlP' | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => GitGutter | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let g:gitgutter_sign_column_always = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment