Created
August 17, 2015 11:05
-
-
Save PeterRincker/6e16e5a82065d7f9809f to your computer and use it in GitHub Desktop.
Center text inside of a comment
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
" FancySmancyComment(text, fill_char, width) | |
" Create comment string with centered text | |
" All arguments are optional | |
function! FancySmancyComment(...) | |
let text = get(a:000, 0, '') | |
let fill = get(a:000, 1, '-')[0] | |
let width = get(a:000, 2, 80) - len(printf(&commentstring, '')) - len(text) | |
let left = width / 2 | |
let right = width - left | |
put=printf(&commentstring, repeat(fill, left) . text . repeat(fill, right)) | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment