Skip to content

Instantly share code, notes, and snippets.

@esycat
Last active December 15, 2015 15:08
Show Gist options
  • Save esycat/5279192 to your computer and use it in GitHub Desktop.
Save esycat/5279192 to your computer and use it in GitHub Desktop.
My Vim config file.
" Don't be compatible with Vi
set nocompatible
" Indentation style
set autoindent
"set smartindent
"set cindent
" Tab behavior
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set nowrap
" Search settings
set incsearch
set hlsearch
" Disable annoying error noises
set noerrorbells
set novisualbell
" Editor settings
set ruler
set number
set numberwidth=5
" Scrolling with context
set scrolloff=3
set sidescrolloff=2
" Backspace magick
set backspace=indent,eol,start
" Keyboard shortcuts
map <F3> :ls<CR>
map <F8> :emenu Encoding.<TAB>
map <F10> :q<CR>
map <SPACE> za
map <C-S> :update<CR>
inoremap <C-S> <C-O>:update<CR>
map <C-o> :browse tabnew <CR>
map <C-t> :tabnew <CR>
map <C-w> :tabclose <CR>
map <C-Tab> :tabn <CR>
map <C-S-Tab> :tabp <CR>
" Write via sudo
cmap w!! %!sudo tee > /dev/null %
let g:author='Eugene Janusov'
let g:email='[email protected]'
let g:company='Persic Entertainment'
if has("syntax")
syntax on
set cursorline
endif
if has("folding")
set foldenable
set foldmethod=syntax " indent
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
filetype plugin on
filetype indent off
" For all text files set 'textwidth' to 120 characters.
autocmd FileType text setlocal textwidth=120
autocmd FileType c,cpp,h,java,scala,csharp,py,php,js,xml,html,css autocmd BufWritePre <buffer> :call RemoveTrailingWhitespaces()
endif
" gVIM and MacVim settings
if has("gui_running")
colors desert
set columns=128
set lines=48
if has("gui_gtk2")
set guifont=Monospace\ 11
elseif has("gui_kde")
elseif has("x11")
elseif has("gui_mac") || has("gui_macvim")
set guifont=Consolas:h14,Monospace:h12
set transparency=1
elseif has("gui_win32")
endif
else
endif
" Menu
set wildmenu
set wcm=<Tab>
" Encoding selection
menu Encoding.UTF-8 :e ++enc=utf-8<CR>
menu Encoding.KOI8-R :e ++enc=koi8-r<CR>
menu Encoding.Windows-1251 :e ++enc=cp1251<CR>
menu Encoding.IBM-866 :e ++enc=ibm866<CR>
" Removes trailing white-spaces
function RemoveTrailingWhitespaces()
if &binary " Never process binary files
return false
endif
" Remember cursor position
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c) " Re-store cursor position
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment