Skip to content

Instantly share code, notes, and snippets.

@akitsukada
Created July 10, 2011 14:55
Show Gist options
  • Save akitsukada/1074599 to your computer and use it in GitHub Desktop.
Save akitsukada/1074599 to your computer and use it in GitHub Desktop.
karaage.vim.tsukada
let s:Presentation = { 'slides' : [], 'current' : 0, 'max' : 0 }
function! s:Presentation.load()
let self.slides = [
\ {
\ 'title' : 'karaage.vim',
\ 'contents' : [
\ '* vimrc晒しとカーソル移動系コマンド紹介',
\ '* 2011/07/10',
\ '* @akitsukada',
\ ]
\ },
\ {
\ 'title' : ' 提供',
\ 'contents' : [
\ 'ネットでつながる。',
\ 'エンターテイメントでつながる。',
\ '    dwango',
\ ]
\ },
\ {
\ 'title' : 'このプレゼンツールは',
\ 'contents' : [
\ 'こちらの記事のものを使わせていただきました。',
\ 'http://d.hatena.ne.jp/maedana/20080523/1211549638',
\ ]
\ },
\ {
\ 'title' : '参考になる変態たち',
\ 'contents' : [
\ '* vim-users.jp',
\ '* http://vim-users.jp/',
\ '* (php)プログラマのためのvim (まとめ)',
\ '* おぎろぐはてな',
\ '* http://d.hatena.ne.jp/i_ogi/20070715/1184480249',
\ ]
\ },
\ {
\ 'title' : 'ワシの.vimrcは108式までうんたら',
\ 'contents' : [
\ '* ~/.vimrc',
\ '* 言わずと知れたvim設定ファイル',
\ '* コマンドが羅列してあるので見てみよう',
\ '* https://github.com/akitsukada/dotfiles',
\ ]
\ },
\ {
\ 'title' : 'コマンドじゃないけど紹介:bundle',
\ 'contents' : [
\ '* プラグイン管理のためのプラグイン vundle',
\ '* 特徴:pathogenと違って自動管理',
\ '*    rails3のbundlerにインスパイアされた',
\ '* インストール:',
\ '* 1 $ cd ~',
\ '* 2 $ mv .vim .vim.bak',
\ '* 3 $ mkdir .vim',
\ '* 4 $ cd .vim',
\ '* 5 $ git clone git://github.com/gmarik/vundle.git',
\ ]
\ },
\ {
\ 'title' : 'カーソル移動系コマンド',
\ 'contents' : [
\ '* カーソルを効率よく動かす',
\ '* 効率よく=少ないキータッチで',
\ ]
\ },
\ {
\ 'title' : '',
\ 'contents' : [
\ '* 「うわっ...私のキータッチ、多すぎ...?」',
\ '                 27歳aさんの場合',
\ ]
\ },
\ {
\ 'title' : '',
\ 'contents' : [
\ '* 「彼氏がj押しっぱなしでスクロールしてた。別れたい...」',
\ '               匿名ダイアリー 増田',
\ ]
\ },
\ {
\ 'title' : '基本hjkl',
\ 'contents' : [
\ '上下左右にうごきますね',
\ '由来:',
\ 'http://www.kagami.org/diary/2005-08-28-1.html',
\ ]
\ },
\ {
\ 'title' : 'pageup, pagedown',
\ 'contents' : [
\ 'pageup: c-u, pagedown: c-d',
\ 'ガッと動きますね',
\ ]
\ },
\ {
\ 'title' : '単語単位',
\ 'contents' : [
\ 'w',
\ '割と日本語も行ける',
\ ]
\ },
\ {
\ 'title' : '任意の文字まで',
\ 'contents' : [
\ 't/t, f/f + 任意の文字',
\ 'tは目的の文字を含まない、fは含む',
\ ]
\ },
\ {
\ 'title' : '対応するカッコにジャンプ',
\ 'contents' : [
\ '%',
\ 'カッコ使う言語の編集中はすごい便利',
\ 'rubyェ...',
\ ]
\ },
\ {
\ 'title' : '前回の編集位置へ(+インサートモード)',
\ 'contents' : [
\ 'gi',
\ 'ファイルとじても有効!',
\ ]
\ },
\ {
\ 'title' : '使いどころ',
\ 'contents' : [
\ 'vやy,d,xと併せて使う',
\ '→素早い編集が可能になる',
\ ]
\ },
\ {
\ 'title' : 'その他よく使うやつ',
\ 'contents' : [
\ ]
\ },
\ {
\ 'title' : '.(dot)',
\ 'contents' : [
\ '一つ前の動作を繰り返す',
\ ]
\ },
\ {
\ 'title' : 'マクロ記録',
\ 'contents' : [
\ 'q[キー] で開始',
\ '〜色々やる〜',
\ 'q で終了',
\ ]
\ },
\ {
\ 'title' : 'ウィンドウ分割系',
\ 'contents' : [
\ ':sp[lit], vsp[lit] [filename]',
\ '左のウィンドウでソースコード、右でテストコードを開くとか',
\ ]
\ },
\ {
\ 'title' : 'タブ系',
\ 'contents' : [
\ ':tabe[dit] [filename]',
\ '一つ目のタブでapp/controllers、二つ目でapp/modelsのファイルを編集とか',
\ ]
\ },
\ {
\ 'title' : 'ブロック操作',
\ 'contents' : [
\ '[operation](a|i)p',
\ '空行で区切られたブロックに対してoperationする',
\ 'ちゃんと空行で区切られたソースコードなら便利',
\ ]
\ },
\ {
\ 'title' : 'フォーマット系',
\ 'contents' : [
\ '== または 選択して=',
\ '== で現在行のインデント',
\ '広い範囲を選択して=でインデントレベルを考慮してfix',
\ ]
\ },
\ {
\ 'title' : 'とりあえず',
\ 'contents' : [
\ '以上',
\ 'ご清聴ありがとうございました',
\ ]
\ },]
let self.current = 0
let self.max = len(self.slides)
endfunction
function! s:Presentation.showPage()
call self.showPageTitle()
call self.showPageContents()
endfunction
function! s:Presentation.showPageTitle()
execute 'normal o '
call setpos('.', [0, winline(), 1, winwidth(0)/5])
execute 'normal i ' . self.currentSlide()['title']
execute 'normal o '
endfunction
function! s:Presentation.showPageContents()
for content in self.currentSlide()['contents']
execute 'normal o '
call setpos('.', [0, winline(), 1, winwidth(0)/6])
execute 'normal i ' . content
endfor
endfunction
function! s:Presentation.currentSlide()
return self.slides[self.current]
endfunction
function! s:Presentation.clearPage()
execute 'normal ggdG'
endfunction
function! s:Presentation.showNextPage()
let nextIndex = self.current + 1
if nextIndex == self.max
echo '最後のページです'
return
endif
call self.clearPage()
let self.current = nextIndex
call self.showPage()
endfunction
function! s:Presentation.showPrevPage()
let prevIndex = self.current - 1
if prevIndex < 0
echo '最初のページです'
return
endif
call self.clearPage()
let self.current = prevIndex
call self.showPage()
endfunction
" 次ページを表示
function! s:ShowNextPage()
call s:Presentation.showNextPage()
endfunction
" 前ページを表示
function! s:ShowPrevPage()
call s:Presentation.showPrevPage()
endfunction
" プレゼンテーションを有効化する
function! s:Enable()
call s:Presentation.load()
set paste
set ve=all
set laststatus=0
" map <buffer> j :call s:Presentation.nextLine()<CR>
" map <buffer> k :call s:Presentation.prevLine()<CR>
map <buffer> h :call <SID>ShowPrevPage()<CR>
map <buffer> l :call <SID>ShowNextPage()<CR>
call s:Presentation.showPage()
endfunction
" プレゼンテーションを無効化する
function! s:Disable()
set nopaste
set ve=
set laststatus=2
endfunction
command! -bar -narg=0 PresentationEnable call s:Enable()
command! -bar -narg=0 PresentationDisable call s:Disable()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment