Created
February 28, 2019 08:23
-
-
Save lusingander/fdf2d210c6ca63123f5a2b07926b0603 to your computer and use it in GitHub Desktop.
vim command util
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" json format (by jq) and syntax highlight | |
function! FormatAndHighlightJsonData() | |
if executable('jq') | |
:%!jq . | |
:set filetype=json | |
endif | |
endfunction | |
ca json call FormatAndHighlightJsonData() | |
" convert unix time to str under cursor | |
function! UnixTimeToStr(unixtime) | |
return strftime("%Y/%m/%d %H:%M:%S", a:unixtime) | |
endfunction | |
function! ConvCursorUnixTimeToStr() | |
let l:thisStr = expand("<cword>") | |
echo UnixTimeToStr(l:thisStr) | |
endfunction | |
ca ut call ConvCursorUnixTimeToStr() | |
function! ConvCursorUnixTimeToStrAndInsert() | |
let l:thisStr = expand("<cword>") | |
execute ":normal A" . " => " . UnixTimeToStr(l:thisStr) | |
endfunction | |
ca uta call ConvCursorUnixTimeToStrAndInsert() | |
function! ConvCursorUnixTimeToStrAndChange() | |
let l:thisStr = expand("<cword>") | |
execute ":normal ciw" . UnixTimeToStr(l:thisStr) | |
endfunction | |
ca utc call ConvCursorUnixTimeToStrAndChange() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment