Skip to content

Instantly share code, notes, and snippets.

@zdxerr
Created February 4, 2011 11:18
Show Gist options
  • Select an option

  • Save zdxerr/810998 to your computer and use it in GitHub Desktop.

Select an option

Save zdxerr/810998 to your computer and use it in GitHub Desktop.
VIM configuration
syntax on
set autoindent
set cindent
set sw=4
set ts=4
" Wrap too long lines
set wrap
" Tabs are 2 characters
set tabstop=4
" (Auto)indent uses 2 characters
set shiftwidth=4
" spaces instead of tabs
set expandtab
" guess indentation
set autoindent
" Expand the command line using tab
set wildchar=<Tab>
" show line numbers
set number
" Fold using markers {
" {{
" like this
" }}}
set foldmethod=marker
" enable all features
set nocompatible
" powerful backspaces
set backspace=indent,eol,start
" highlight the searchterms
set hlsearch
" jump to the matches while typing
set incsearch
" ignore case while searching
set ignorecase
" don't wrap words
set textwidth=0
" history
set history=50
" 1000 undo levels
set undolevels=1000
" show a ruler
set ruler
" show partial commands
set showcmd
" show matching braces
set showmatch
" write before hiding a buffer
set autowrite
" allows hidden buffers to stay unsaved, but we do not want this, so comment
" it out:
"set hidden
"set wmh=0
" auto-detect the filetype
filetype plugin indent on
" syntax highlight
syntax on
" Always show the menu, insert longest match
set completeopt=menuone,longest
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" I like highlighting strings inside C comments
let c_comment_strings=1
set encoding=utf-8
set scrolloff=3
set autoindent
set showmode
set showcmd
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set laststatus=2
"set relativenumber
set undofile
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set gdefault
" handling long lines
set wrap
set textwidth=79
set formatoptions=qrn1
set colorcolumn=80
" disabling some keys
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
" save file on losing focus of vim
au FocusLost * :wa
" let / + w open new vertical split and switch to it
nnoremap <leader>w <C-w>v<C-w>l
" remove some gui widgets
:set guioptions-=m "remove menu bar
:set guioptions-=T "remove toolbar
:set guioptions-=r "remove right-hand scroll bar
" use file dir as working dir
set autochdir
map <F5> :call CompileRunGcc()<CR>
map <F8> : call CompileGcc()<CR>
func! CompileRunGcc()
exec "w" "Save the file
exec "make"
exec "elogread.exe"
exec "i" "jump back where we were
endfunc
" Save and make current file.o
function! Make()
let curr_dir = expand('%:h')
if curr_dir == ''
let curr_dir = '.'
endif
echo curr_dir
execute 'lcd ' . curr_dir
execute 'make %:r.o'
execute 'lcd -'
endfunction
nnoremap <F7> :update<CR>:call Make()<CR>
func! CompileGcc()
exec "w"
exec "!gcc % -o %< && IF EXIST %<.exe (cr 5 && banner -c # Success) ELSE banner -c # Compile Unsuccessful "
exec "i"
endfun
set undodir=E:/backup/vim/undo
" Setup backup location and enable
set backupdir=E:/backup/vim
set backup
" Set Swap directory
set directory=E:/backup/vim/swap
" GUI Settings {
if has("gui_running")
" Basics {
colorscheme mustang " my color scheme (only works in GUI)
set columns=180 " perfect size for me
set guifont=Consolas:h11 " My favorite font
set guioptions=ce
" ||
" |+-- use simple dialogs rather than pop-ups
" + use GUI tabs, not console style tabs
set lines=55 " perfect size for me
" set mousehide " hide the mouse cursor when typing
language messages en
set langmenu=en_US.UTF-8
" }
" Font Switching Binds {
map <F8> <ESC>:set guifont=Consolas:h8<CR>
map <F9> <ESC>:set guifont=Consolas:h11<CR>
map <F10> <ESC>:set guifont=Consolas:h12<CR>
map <F11> <ESC>:set guifont=Consolas:h16<CR>
map <F12> <ESC>:set guifont=Consolas:h20<CR>
" }
endif
" }
" NERDTree Customization
let NERDChristmasTree=1
let NERDTreeIgnore=['\.o$', '\.exe$', '\.dll$']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment