Skip to content

Instantly share code, notes, and snippets.

@kaiquewdev
Created September 25, 2011 07:06
Show Gist options
  • Save kaiquewdev/1240322 to your computer and use it in GitHub Desktop.
Save kaiquewdev/1240322 to your computer and use it in GitHub Desktop.
my_vimrc
syntax on " Syntax color
set number " Numeration line by line
colorscheme torte " Set a desert scheme to default
" Search color
hi Search cterm=none ctermbg=4 ctermfg=15
set hlsearch
" History
set history=700
" Autoread
set autoread
" Extra key
let mapleader = ','
let g:mapleader = ','
" Fast saving
nmap <leader> w :w!<cr>
" Fast editing a vimrc
map <leader>e :e! ~/.vim_runtime/vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc
" Set seven lines for cursor
set so=7
" Wild menu
set wildmenu
" Show the current position
set ruler
" Command bar height
set cmdheight=2
" Change buffer without saving
set hid
" Backspace configuration
set backspace=eol,start,indent
" Ignore case when searching
set ignorecase
set smartcase
set incsearch " Mark search with ink
set nolazyredraw " Don't readraw while executing macros
set magic " Magic on for regular expressions
set showmatch " Show matching bracets when text indicator is over them
set mat=2 " How many tenths of a second to blink
" No sounds on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
syntax enable "Enable syntax hl
" Encoding
set encoding=utf8
" Default file types
set ffs=unix,dos,mac
" Text, tab and indent
set expandtab
set shiftwidth=4
set tabstop=4
set smarttab
set lbr
set tw=500
set ai " Auto indent
set si " Smart indent
set wrap " Wrap lines
" Moving arround tabs and buffers
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
" Always hide the statusline
set laststatus=2
" expandigs and completitions
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i
" File type completition
filetype plugin on
set ofu=syntaxcomplete#Complete
" Tab completition
function! Smart_TabComplete()
let line = getline('.') " curline
let substr = strpart(line, -1, col('.')+1) " from start to cursor
let substr = matchstr(substr, "[^ \t]*$") " word till cursor
if (strlen(substr)==0) " nothing to match on empty string
return "\<tab>"
endif
let has_period = match(substr, '\.') != -1 " position of period, if any
let has_slash = match(substr, '\/') != -1 " position of slash, if any
if (!has_period && !has_slash)
return "\<C-X>\<C-P>" " existing text matching
elseif ( has_slash )
return "\<C-X>\<C-F>" " file matching
else
return "\<C-X>\<C-O>" " plugin matching
endif
endfunction
inoremap <c-space> <c-r>=Smart_TabComplete()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment