Skip to content

Instantly share code, notes, and snippets.

@guelau
Last active November 8, 2024 16:30
Show Gist options
  • Save guelau/d2b6ccc2c5bb3dd0fdbc to your computer and use it in GitHub Desktop.
Save guelau/d2b6ccc2c5bb3dd0fdbc to your computer and use it in GitHub Desktop.
My personal vimrc
"""""""""""""""""""""""""""""""""""""
" GENERAL
"""""""""""""""""""""""""""""""""""""
set nocompatible
set history=500
" undo, pour revenir en arrière
set undolevels=150
" vim monitor realtime changes to a file
set autoread
"""""""""""""""""""""""""""""""""""""
" FILE
"""""""""""""""""""""""""""""""""""""
" Using multi-byte UTF-8 encoding
scriptencoding utf-8
set encoding=utf-8
" File type = Unix
set ffs=unix,dos,mac
set nostartofline
set backspace=indent,eol,start
set backup
" Backup dans ~/.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
if has("syntax")
syntax on
endif
"""""""""""""""""""""""""""""""""""""
" TAB AND INDENT
"""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
set smarttab
" tab = 4 spaces
set tabstop=4
set shiftwidth=4
" always set autoindenting on
set autoindent
" smart indent
set smartindent
" set cindent
set noautoindent
"set nosmartindent
set nocindent
"""""""""""""""""""""""""""""""""""""
" DISPLAY
"""""""""""""""""""""""""""""""""""""
" No sound and visual errors
set errorbells
set novisualbell
set t_vb=
set tm=500
" Show matching brackets when text indicator is over them
set showmatch
" How many seconds showing the matching brackets
"set matchtime=2
" status bar
set laststatus=2
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
" Format
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
" Show current position
set ruler
colorscheme desert
set background=dark
" 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
" Highlighting the line where is the cursor
function s:SetCursorLine()
set cursorline
" show line numbers
" set number
highlight CursorLine cterm=NONE ctermbg=DarkBlue ctermfg=LightYellow guibg=DarkBlue guifg=white
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
endfunction
"set cursorline
autocmd VimEnter * call s:SetCursorLine()
" Height of the command bar
set cmdheight=2
"""""""""""""""""""""""""""""""""""""
" SEARCHING
"""""""""""""""""""""""""""""""""""""
" 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
set scrolloff=3
set showcmd
set ttyfast
" For regular expressions turn magic on
set magic
"""""""""""""""""""""""""""""""""""""
" LEADER
"""""""""""""""""""""""""""""""""""""
" Set a map leader
" eq. <leader>w saves the current file
let mapleader = ";"
let g:mapleader = ";"
" Fast saving
nmap <leader>w :w!<cr>
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
"""""""""""""""""""""""""""""""""""""
" BUFFER AND TABS
"""""""""""""""""""""""""""""""""""""
" Map <Space> to / (search) and Ctrl-<Space> to ? (backwards search)
map <space> /
map <c-space> ?
" Close the current buffer
map <leader>bd :Bclose<cr>
"""""""""""""""""""""""""""""""""""""
" DEVELOPER OPTIONS
"""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
if has("autocmd")
set omnifunc=syntaxcomplete#Complete
"au filetype html set omnifunc=htmlcomplete#CompleteTags
"au filetype css set omnifunc=csscomplete#CompleteCSS
"au filetype javascript set omnifunc=javascriptcomplete#CompleteJS
"au filetype php set omnifunc=phpcomplete#CompletePHP
"au filetype xml set omnifunc=xmlcomplete#CompleteTags
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
au FileType helpfile set nonumber " no line numbers when viewing help
au FileType helpfile nnoremap <buffer><cr> <c-]> " Enter selects subject
au FileType helpfile nnoremap <buffer><bs> <c-T> " Backspace to go back
au FileType mail,tex set textwidth=72
au FileType cpp,c,java,sh,pl,php,asp set autoindent
au FileType cpp,c,java,sh,pl,php,asp set smartindent
au FileType cpp,c,java,sh,pl,php,asp set cindent
au BufNewFile,BufRead *.pls set syntax=dosini
au BufNewFile,BufRead modprobe.conf set syntax=modconf
endif
@guelau
Copy link
Author

guelau commented Oct 23, 2014

Installation

mkdir ~/.config
git clone https://gist.github.com/d2b6ccc2c5bb3dd0fdbc.git ~/.config/vimrc
ln -sf ~/.config/vimrc ~/.vimrc

@guelau
Copy link
Author

guelau commented Nov 8, 2024

Capture d’écran 2024-11-08 à 17 30 19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment