Skip to content

Instantly share code, notes, and snippets.

View hokaccha's full-sized avatar

Kazuhito Hokamura hokaccha

View GitHub Profile
function! g:Hatena(arg, line1, line2)
perl << EOF
use Text::Hatena;
my ($success, $firstline) = VIM::Eval('a:line1');
my ($success, $lastline) = VIM::Eval('a:line2');
my $base_text = join "\n", $curbuf->Get($firstline .. $lastline);
my $parse_text = Text::Hatena->parse($base_text);
function! VisualCurrentIndentBlock()
let current_indent = indent('.')
let current_line = line('.')
let current_col = col('.')
let last_line = line('$')
let start_line = current_line
while start_line != 1 && current_indent == indent(start_line - 1)
let start_line = start_line - 1
endwhile
" HTMLとかでドキュメントルートからの絶対パスのファイルを開く(gfみたいな感じで)
" 絶対パスじゃなかったら(/で始まってなかったら)gfと同じ
" ドキュメントルートのディレクトリは配列で複数指定できる。
let s:root_dirs = [$HOME.'/dev/site/localhost/test']
function! GotoAbsFile()
let filename = expand('<cfile>')
let filepath = filename
if (match(filename, '^/') != -1)
for dir in s:root_dirs
function! ZoomToggle()
let normal_font = 'Monaco:h12'
let zoom_font = 'Monaco:h25'
if &guifont == normal_font
let font = zoom_font
let columns = 78
let lines = 22
else
let font = normal_font
let columns = 180
" Macでクリップボードにコピーするoperator
if has('mac')
function! Pbcopy(type, ...)
let reg_save = @@
if a:0
silent execute "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
silent execute "normal! '[V']y"
elseif a:type == 'block'
silent execute "normal! `[\<C-V>`]y"
" ウインドウ単位で開いたファイルの履歴をたどる
function! FileJumpPush()
if !exists('w:histories')
let w:histories = []
endif
let buf = bufnr('%')
if count(w:histories, buf) == 0
call add(w:histories, buf)
endif
endfunction
" snipMate再読み込み。xxx.snippetを開いているときに:call SnipMateReload()すればOK
function! SnipMateReload()
if &ft == 'snippet'
let ft = substitute(expand('%'), '.snippets', '', '')
if has_key(g:did_ft, ft)
unlet g:did_ft[ft]
endif
silent! call GetSnippets(g:snippets_dir, ft)
endif
endfunction
" textobj-template - Text objects for WAF template engine.
" Version: 0.0.1
" Author: Kazuhito Hokamura
" License: MIT license (see <http://www.opensource.org/licenses/mit-license>)
if exists('g:loaded_textobj_template')
finish
endif
call textobj#user#plugin('template', {
" textobj-camelcase - Text objects for camel case.
" Version: 0.0.1
" Author: Kazuhito Hokamura
" License: MIT license (see <http://www.opensource.org/licenses/mit-license>)
if exists('g:loaded_textobj_camelcase')
finish
endif
call textobj#user#plugin('camelcase', {
#!/usr/bin/env perl
use strict;
use warnings;
use AnyEvent::Twitter::Stream;
use AnyEvent::HTTP;
use HTTP::Request::Common;
my $done = AnyEvent->condvar;