Skip to content

Instantly share code, notes, and snippets.

@gullevek
Created August 20, 2015 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gullevek/544607cde4ca11416a19 to your computer and use it in GitHub Desktop.
Save gullevek/544607cde4ca11416a19 to your computer and use it in GitHub Desktop.
VIM config file
set nocompatible
set hidden " background buffers
set history=1000
set wildmenu " tab complete like bash
" set ignorecase " ignore case for search
" set smartcase " but if capital letter, make case sensitive again
set scrolloff=3 " keep 3 lines before/after
set bs=2 " backspace command, alt: indent,eol,start
set noexpandtab
set tabstop=4
set softtabstop=4 " soft tab, only important if tabstop > than softtabstop
set shiftwidth=4 " if > or < is used
set noexpandtab
set ruler
syn on
filetype plugin indent on
set autoindent
" set smartindent
set laststatus=2 " always show bottom info line
"set cmdheight=2 " bottom info bar hight, keep at 1 for the moment, any
set showtabline=1 " top tab bar, only if tabs are used
set incsearch " show match during search
set showmatch
set showcmd
set showmode
set hlsearch
set pastetoggle=<F11>
set nolbr
"set cursorline " highlight cursor pos
set ttyfast " smoother changes
"set t_Co=256
set whichwrap=b,s,h,l,<,>,[,] " move freely between files
" default listchars
set listchars=tab:\→\ ,trail:▫︎,nbsp:•,eol:¶,extends:»,precedes:«
"colorscheme desert
"colorscheme badwolf
colorscheme default
" Show Numbers On/Off
map <F10> :call Number_on_off()<CR>
map <F12> :call List_on_off()<CR>
" Gundo Undo Tree
nnoremap <F5> :GundoToggle<CR>
let g:gundo_preview_bottom = 1 " show the diff window below the main window
let number_mode = 0 " 0 = normal, 1 = show number
let list_mode = 0 " 0 = normal, 1 = show tabs
function! ToggleNumber()
if(&relativenumber == 1)
set norelativenumber
else
set relativenumber
endif
endfunc
func! Number_on_off()
if g:number_mode == 0
set nu
let g:number_mode = 1
else
set nonu
let g:number_mode = 0
endif
return
endfunc
func! List_on_off()
if g:list_mode == 0
set listchars=tab:\→\ ,trail:▫︎,nbsp:•
set list
let g:list_mode = 1
else
set listchars=tab:\→\ ,trail:▫︎,nbsp:•,eol:¶,extends:»,precedes:«
set nolist
let g:list_mode = 0
endif
return
endfunc
" just for testing
function! ShowColors()
let num = 255
while num >= 0
exec 'hi col_'.num.' ctermbg='.num.' ctermfg=white'
exec 'syn match col_'.num.' "ctermbg='.num.':...." containedIn=ALL'
call append(0, 'ctermbg='.num.':....')
let num = num - 1
endwhile
endfunction
" tab keys
map <C-t><up> :tabr<cr>
map <C-t><down> :tabl<cr>
map <C-t><left> :tabp<cr>
map <C-t><right> :tabn<cr>
hi TabLine ctermbg=white
hi TabLineFill ctermfg=black ctermbg=white
hi TabLineSel ctermbg=red ctermfg=white
hi statusline ctermbg=black ctermfg=darkyellow
hi statuslineNC ctermbg=yellow ctermfg=darkgrey
hi ModeMsg cterm=bold ctermfg=yellow ctermbg=red
set statusline=%f\ %#error#%m%*[%{strlen(&fenc)?&fenc:'none'},%{&ff}]%h%#error#%r%*%y%=%-20([%n]\ %c%V,%l/%L%)\ [%o]\ %p%%
"%#error#%{&paste?'[paste]':''}%*
" update curring vim with new vimrc settings
map ,u :source ~/.vimrc<cr>
" turn off search highlighted words
noremap ,<space> :nohlsearch<CR>
" highlight last inserted text
nmap gV `[v`]
if exists("+showtabline")
function! MyTabLine()
let s = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let s .= ' ['
let s .= i . ':'
let s .= winnr . '/' . tabpagewinnr(i,'$')
let s .= ' %*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let file = bufname(buflist[winnr - 1])
let file = fnamemodify(file, ':p:t')
if file == ''
let file = '[No Name]'
endif
let s .= '%m'
let s .= file
let s .= '] '
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
set stal=1
set tabline=%!MyTabLine()
endif
" folding
" optional set fdm=manual
inoremap <F9> <C-O>za
nnoremap <F9> za
onoremap <F9> <C-C>za
vnoremap <F9> zf
" turn off fold depth side bar (2)
map <F8> :call FoldSideBar_on_off()<CR>
let foldsidebar_mode = 0
func! FoldSideBar_on_off()
if g:foldsidebar_mode == 0
set fdc=2
let g:foldsidebar_mode = 1
else
set fdc=0
let g:foldsidebar_mode = 0
endif
return
endfunc
" set cursorline on off
map <F7> :call Cursorline_on_off()<CR>
let cursorline_mode = 0
func! Cursorline_on_off()
if g:cursorline_mode == 0
set cursorline
let g:cursorline_mode = 1
else
set nocursorline
let g:cursorline_mode = 0
endif
return
endfunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment