Created
August 29, 2011 12:45
-
-
Save kosei27/1178317 to your computer and use it in GitHub Desktop.
Centering text..
This file contains hidden or 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
" .@:CenteringText {{{1 | |
" | |
" 例えば、「|」にカーソルがある状態で、 | |
" | |
" /* ------------------------------ | |
" * | hoge | |
" * ------------------------------ */ | |
" | |
" :call CenteringText(30)といった感じで、 | |
" 引数に「-」の数を指定して実行すると、 | |
" | |
" /* ------------------------------ | |
" * hoge | |
" * ------------------------------ */ | |
" | |
" という風にセンタリングされます。。。 | |
function! CenteringText(width) | |
set expandtab | |
" カーソル位置から行頭まで削除してビジュアルモードに移行。 | |
silent normal d0v | |
execute "center".a:width | |
execute "normal \<Esc>" | |
" 最初に削除したテキストを行頭に追加して戻す。 | |
silent normal 0P | |
set noexpandtab | |
endfunction | |
nmap <Space>ct :<C-u>call CenteringText()<Left> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment