Skip to content

Instantly share code, notes, and snippets.

@kxzk
Created January 8, 2018 04:15
Show Gist options
  • Save kxzk/4896d55bbaa5b5ffc7ab91bbbb378100 to your computer and use it in GitHub Desktop.
Save kxzk/4896d55bbaa5b5ffc7ab91bbbb378100 to your computer and use it in GitHub Desktop.
function! FileSize() abort
let l:bytes = getfsize(expand('%p'))
if (l:bytes >= 1024)
let l:kbytes = l:bytes / 1025
endif
if (exists('kbytes') && l:kbytes >= 1000)
let l:mbytes = l:kbytes / 1000
endif
if l:bytes <= 0
return '0'
endif
if (exists('mbytes'))
return l:mbytes . 'MB '
elseif (exists('kbytes'))
return l:kbytes . 'KB '
else
return l:bytes . 'B '
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment