Skip to content

Instantly share code, notes, and snippets.

@asterix24
Created September 21, 2015 19:41
Show Gist options
  • Save asterix24/4b4b18991788c4f0357d to your computer and use it in GitHub Desktop.
Save asterix24/4b4b18991788c4f0357d to your computer and use it in GitHub Desktop.
My Vim Settings
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
set shell=/bin/bash
" #### Plugins whit vundle ####
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
"GruvBox Vim color scheme
Plugin 'morhetz/gruvbox'
"NerdTree Plugin - directory explorer -
Plugin 'scrooloose/nerdtree'
" Buffer expore plugin
Plugin 'jlanzarotta/bufexplorer'
" File explorer
Plugin 'kien/ctrlp.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'fatih/vim-go'
call vundle#end() " required
filetype plugin indent on " required
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" bernie: most terminal emulators support this
set t_Co=256
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set hlsearch " Highlight previous search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
set mouse=a " Enable mouse usage (all modes)
set backspace=2
"Indetentation
set nowrap
set sidescroll=3
set sidescrolloff=8
set scrolloff=3
set listchars=extends:>,precedes:<,tab:\|\ ,trail:-,nbsp:%
set list
set tabstop=4
set sw=4
set sts=4
set smartindent
" Colors and layout settings.
" Use gruvebox theme.
" disable italic becouse highlight comment strings
colorscheme gruvbox
let g:gruvbox_italic=0
set background=dark
"Show line numbers
set number
"highlight numbers and status bar
highlight LineNr term=bold cterm=NONE ctermfg=DarkGray ctermbg=NONE
"Display always status line
set laststatus=2
set statusline=\ \ \ %f%m%r%h%w\ [%{&ff}]\ [%Y]\ {0x%04.4B,%04b}\ lin.%05l\ col.%04v\ pos.%p%%\ %{strftime(\"%d/%m/%Y\ -\ %H:%M\")}
highlight statusline term=bold cterm=NONE ctermfg=black ctermbg=gray
" #############################################################################
"Asterix: my personal keyboard shortcut
map <S-Left> :bprevious <Enter>
map <S-Right> :bnext <Enter>
map <S-Tab> :b# <Enter>
map <C-n> :vert sb# <Enter>
"activate visual mode in normal mode
nmap <S-Up> V
nmap <S-Down> V
" these are mapped in visual mode
vmap <S-Up> k
vmap <S-Down> j
"Tab per identare
vmap <tab> >
"Show hide line numbers
nmap <C-N><C-N> :set invnumber<CR>
" Map key to navigate in vim splits
nmap <C-j> <C-w><C-w>j
nmap <C-l> <C-w><C-w>l
nmap <C-k> <C-w><C-w>k
nmap <C-h> <C-w><C-w>h
"Asterix: clean file from trailing space.
:nnoremap <silent> <F4> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
"Gestione dei tags
map <F5> :tp <Enter>
map <F6> :tn <Enter>
"Compilazione
map <F7> :make <Enter>
map <F8> :make clean <Enter>
"Directory view e chiusura
map <F9> :bdelete <Enter>
map <F11> :ls <Enter>
map <F12> :NERDTreeToggle <Enter>
map <S-F12> :BufExplorer <Enter>
" bernie: search for highlighted text
:vmap // y/<C-R>
" piro: no, I don't want your fucking help!
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" w!! if you forget to sudo before saving
cmap w!! w !sudo tee % >/dev/null
" Repeat last command and put cursor at start of change -- http://vim.wikia.com/wiki/VimTip1142
map . .`[
" bernie: ex mode is useless and annoying
map Q <Nop>
" #############################################################################
"Gestione sorgenti
" Asterix simple macro to swich source/header
set path=.,,..,../..,./*,./*/*,../*,~/,~/**,/usr/include/*
function! Mosh_Flip_Ext()
" Switch editing between .c* and .h* files (and more).
" Since .h file can be in a different dir, call find.
if match(expand("%"),'\.c') > 0
let s:flipname = substitute(expand("%"),'\.c\(.*\)','.h\1',"")
exe ":find " s:flipname
elseif match(expand("%"),"\\.h") > 0
let s:flipname = substitute(expand("%"),'\.h\(.*\)','.c\1',"")
exe ":find " s:flipname
endif
endfun
map <F2> :call Mosh_Flip_Ext()<CR>
" Hex mode
noremap <S-H> :call HexMe()<CR>
let $in_hex=0
function! HexMe()
set binary
set noeol
if $in_hex>0
:%!xxd -g1 -r
let $in_hex=0
else
:%!xxd -g1
let $in_hex=1
endif
endfunction
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment