Skip to content

Instantly share code, notes, and snippets.

Avatar

Kazuhito Hokamura hokaccha

View GitHub Profile
View hatena.vim
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);
View visualCurrentIndentBlock.vim
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
View gotoAbsFile.vim
" 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
View zoom.vim
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
View pbcopy.vim
" 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"
View filejump.vim
" ウインドウ単位で開いたファイルの履歴をたどる
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
View snipMateReload.vim
" 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
View template.vim
" 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', {
View camelcase.vim
" 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', {
View twitter2im.pl
#!/usr/bin/env perl
use strict;
use warnings;
use AnyEvent::Twitter::Stream;
use AnyEvent::HTTP;
use HTTP::Request::Common;
my $done = AnyEvent->condvar;
You can’t perform that action at this time.