Skip to content

Instantly share code, notes, and snippets.

@bootleq
bootleq / gist:554634
Created August 28, 2010 03:15
[.vimrc] Simple text object for continuous comment @see http://bootleq.blogspot.com/2010/08/text-object.html
" NOTE: limitations
" 1. Only test if first non-blank character is highlighted with "Comment".
" 2. Always linewise.
vnoremap <silent> ac :<C-U>call TxtObjComment()<CR>
onoremap <silent> ac :<C-U>call TxtObjComment()<CR>
fun! TxtObjComment()
if exists("g:syntax_on")
if ! IsInComment()
echomsg 'Not in a Comment region.'
return 0
@bootleq
bootleq / gist:555806
Created August 29, 2010 01:16
[.vimrc] simple functions to save/restore position, register or mark.
" 暫存/復原 position {{{2
" @params stash/pop
function PosStash(...)
let l:stash = a:0 > 0 ? a:1 : 0
if l:stash
let s:stashCursor = getpos(".")
let g:stashCursor = s:stashCursor
else
call setpos('.', s:stashCursor)
" Most adopted from Bob Hiestand's vsccommand plugin
" http://www.vim.org/scripts/script.php?script_id=90
command! -nargs=? GitDiff cal GitDiff(<f-args>)
function! GitDiff(...)
let rev = "HEAD~" . (a:0 > 0 ? a:1 : 0)
let oldDir = getcwd()
let newDir = fnameescape(expand('%:p:h'))
let filetype = &filetype
let cdCommand = haslocaldir() ? 'lcd' : 'cd'
@bootleq
bootleq / upgrade_git.sh
Created September 15, 2015 12:08
Install git from source
#!/bin/bash
if which apt-get 2>&1 >/dev/null; then
sudo apt-get install -y libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
fi
cd ~/src
[[ ! -d git ]] && git clone https://github.com/git/git --depth 10
@bootleq
bootleq / gist:738007
Created December 12, 2010 12:29
[vimrc] ShowMarks and wokmarks.vim
" }}}2 ShowMarks {{{2
let g:showmarks_include='abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
let g:showmarks_ignore_type=""
let g:showmarks_textlower="\t"
let g:showmarks_textupper="\t"
let g:showmarks_textother="\t"
let g:showmarks_auto_toggle = 0
nnoremap <silent> mo :ShowMarksOn<CR>
nnoremap <silent> mt :ShowMarksToggle<CR>
@bootleq
bootleq / gist:753121
Created December 23, 2010 15:30
按 <LocalLeader>cc 就能 toggle comment 的設定(使用 tComment plugin)
"「關閉這功能。我也忘記是幹嘛的了,既然如此,大概用不太到吧」
let g:tcommentMapLeaderOp1 = ''
let g:tcommentMapLeaderOp2 = ''
"「這個只要加在 vimrc 就能控制 comment 要不要縮排了!」——料理東西軍
let g:tc_option = ' col=1'
noremap <silent> <expr> <LocalLeader>cc ":TComment " . (exists('b:tc_option') ? b:tc_option : g:tc_option) . "<CR>"
noremap <silent> <expr> <LocalLeader>cb ":TCommentBlock " . (exists('b:tc_option') ? b:tc_option : g:tc_option) . "<CR>"
noremap <silent> <expr> <LocalLeader>ci ":TCommentInline " . (exists('b:tc_option') ? b:tc_option : g:tc_option) . "<CR>"
noremap <silent> <expr> <LocalLeader>c$ ":TCommentRight " . (exists('b:tc_option') ? b:tc_option : g:tc_option) . "<CR>"
@bootleq
bootleq / jslint.js
Created December 25, 2010 07:49
Using JSLint command within Vim. See http://bootleq.blogspot.com/2010/12/jslint-vim.html
#!/bin/bash
RHINO_JAR_FILE="$HOME/scripts/rhino.jar"
RHINO_JAR_CLASS="org.mozilla.javascript.tools.shell.Main"
JSLINT_JS_FILE="$HOME/scripts/jslint.js"
java -cp $RHINO_JAR_FILE $RHINO_JAR_CLASS $JSLINT_JS_FILE $@
@bootleq
bootleq / zh-TW.json
Created February 26, 2011 14:34
formcheck.js v.1.7 Traditional Chinese (zh-TW) locale.
{
"definitions" : {
"required" : "這個欄位必須填寫。",
"alpha" : "這個欄位只接受英文字母。",
"alphanum" : "這個欄位只接受英文或數字。",
"nodigit" : "不接受數字。",
"digit" : "請輸入有效的整數。",
"digitmin" : "數字必須大於 %0",
"digitltd" : "數值必須介於 %0 與 %1 之間",
"number" : "請輸入有效的數字。",
@bootleq
bootleq / gist:1033680
Created June 19, 2011 02:30
非 bootleq 登入時,也能讀取 /etc/users/bootleq/ 下的 runtime files
" 非 bootleq 登入時,也能讀取 /etc/users/bootleq/ 下的 runtime files
if expand("<sfile>") == '/etc/users/bootleq/.vimrc'
\ && substitute(system("whoami"), '\n$', '', '') != 'bootleq'
\ && ! exists("did_bootleq_runtime")
set runtimepath+=/etc/users/bootleq/.vim
let did_bootleq_runtime = 1
runtime! plugin/*.vim ftdetect/*.vim after/**/*.vim
endif
@bootleq
bootleq / space-ao.vim
Created July 3, 2011 03:17 — forked from ujihisa/space-ao.vim
See first comment
" Modified from kana's useful tab function {{{
function! s:move_window_into_tab_page(...)
" Move the current window into target_tabpagenr.
" a:1 - target_tabpagenr : if not set, move into new tab page.
" a:2 - open_relative : open new tab aside current tab (default 1).
let target_tabpagenr = a:0 > 0 ? a:1 : 0
let open_relative = a:0 > 1 ? a:2 : 1
if target_tabpagenr > tabpagenr('$')
let target_tabpagenr = tabpagenr('$')