Skip to content

Instantly share code, notes, and snippets.

@ondrasek
Created May 26, 2013 10:19
Show Gist options
  • Save ondrasek/5652349 to your computer and use it in GitHub Desktop.
Save ondrasek/5652349 to your computer and use it in GitHub Desktop.
My .vimrc / _vimrc configuration file.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""
"" Ondruv megazazracnysuperhyperultrasuprafreecoolinkonfigurag
""
"" Copyright (c) Ondra
""
"" Tento konfigurak byl zplagiatorovan Gaussem
""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
version 7.0
language messages en_US
set nocompatible
set nobackup
set writebackup
set autoread
set autowrite
set incsearch
set history=50
set backspace=indent,eol,start
set noexpandtab
set shiftwidth=4
set tabstop=4
set textwidth=0
set display=lastline
set nowrap
set showmatch
set showmode
set ruler
set helplang=en
set langmenu=en
set guifont=Lucida_Console:h14:cEASTEUROPE
set guioptions=aegimtTR
set window=45
set number
set numberwidth=5
set scrolloff=3
"" Color Settings
set background=dark
colorscheme darkblue
"" Highliting
syntax on
set hlsearch
hi LineNr guifg=LightGreen
"" Keyboard and Mouse
set mousemodel=popup
set keymodel=startsel,stopsel
set selection=exclusive
set selectmode=mouse,key
set whichwrap=b,s,<,>,[,]
"" Encodings
set encoding=utf8
set fileencodings=ucs-bom,utf8,latin2,cp1250,default,latin1
"" Status Line
function StatusLine_GetBasicFileInfo()
let basicInfo = []
"" Retrieve File Format
if &fileformat == ""
let basicInfo = add(basicInfo, "??")
else
let basicInfo = add(basicInfo, &fileformat)
endif
"" Retrieve File Type
if &filetype == ""
let basicInfo = add(basicInfo, "??")
else
let basicInfo = add(basicInfo, &filetype)
endif
"" Retrieve File Encoding
if &fileencoding != ""
if &encoding != ""
if (&fileencoding != &encoding)
let basicInfo = add(basicInfo, "file=" . &fileencoding)
let basicInfo = add(basicInfo, "enc=" . &encoding)
else
let basicInfo = add(basicInfo, &encoding)
endif
else
let basicInfo = add(basicInfo, &fileencoding)
endif
else
if &encoding != ""
let basicInfo = add(basicInfo, &encoding)
else
let basicInfo = add(basicInfo, "enc?")
endif
endif
return "|" . join(basicInfo, ":") . "|"
endfunction
function StatusLine_GetBufferFlags()
let bufferFlags = []
"" Buffer Type
if &buftype
let bufferFlags = add(bufferFlags, &buftype)
endif
"" Retrieve modified flag.
if &modified
let bufferFlags = add(bufferFlags, "modified")
"" Check last saved time.
if b:lastSavedTime == 0
let bufferFlags = add(bufferFlags, "%3*unsaved%2*")
else
let age = localtime() - b:lastSavedTime
if age > 180
let bufferFlags = add(bufferFlags, "%3*unsaved%2*")
endif
endif
endif
if ! &modifiable
let bufferFlags = add(bufferFlags, "nomod")
endif
let bufferFlagsStr = join(bufferFlags, ":")
if strlen(bufferFlagsStr) > 0
let bufferFlagsStr = "|" . bufferFlagsStr . "| "
endif
return bufferFlagsStr
endfunction
function StatusLine_GetFileSize()
"" Instead of b:currentFileName we may simply put expand() here.
let fileSize = getfsize(b:currentFileName)
let unit = "b"
if fileSize < 0
let fileSize = 0
endif
if fileSize > 1024
let fileSize = fileSize / 1024
let unit = "KiB"
endif
if fileSize > 1024
let fileSize = fileSize / 1024
let unit = "MiB"
endif
return string(fileSize) . unit
endfunction
function StatusLine_GetModifiedTime()
let modifiedTimeStr = strftime("%c", getftime(b:currentFileName))
return "|ftime:" . modifiedTimeStr . "|"
endfunction
"" Set the current file name of a file opened in the current buffer.
let b:currentFileName = ""
let b:lastSavedTime = 0
autocmd BufNew,BufRead,BufCreate,BufFilePost * let b:currentFileName = expand("%:p")
autocmd BufWritePost * let b:lastSavedTime = localtime()
autocmd BufRead * let b:lastSavedTime = localtime()
"" Groups User2..4 are used for status line elements coloring.
hi User2 guifg=LightGray guibg=DarkGray
hi User3 guifg=DarkRed guibg=DarkGray
hi User4 guifg=Yellow guibg=#000040
"" GetStatusLine
function GetStatusLine()
let statusLine = "%4* buf %n:%2*%<%f%3*%(%r%h%)%2* " . StatusLine_GetBufferFlags() . StatusLine_GetBasicFileInfo() . " " . StatusLine_GetModifiedTime() . " %Ll," . StatusLine_GetFileSize() . "%=|%b,0x%B| %l,%c%V %P "
return statusLine
endfunction
"" Here goes the mighty status line...
set laststatus=2
"" set statusline=%4*\-\-\ %n:%2*\%<%f%3*%(%r%h%)%2*\ %{StatusLine_GetBufferFlags()}%{StatusLine_GetBasicFileInfo()}\ %{StatusLine_GetModifiedTime()}\ %Ll,%{StatusLine_GetFileSize()}%=\|%b,0x%B\|\ \ %l,%c%V\ \ %P
set statusline=%!GetStatusLine()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment