Skip to content

Instantly share code, notes, and snippets.

@bootleq
bootleq / multi-lang.txt
Created August 1, 2010 09:49
text sample contains multi-language characters.
copy from http://meta.wikimedia.org/wiki/List_of_Wikipedias
Anglo-Saxon (ang)
العربية (ar)
سنڌي (sd)
Azərbaycan (az)
Български (bg)
বাংলা (bn)
Català (ca)
Česky (cs)
set tabline=%!SetTabLine()
function! SetTabLine()
" NOTE: left/right padding of each tab was hard coded as 1 space.
" NOTE: require Vim 7.3 strwidth() to display fullwidth text correctly.
" settings
let tabMinWidth = 0
let tabMaxWidth = 40
let tabMinWidthResized = 15
@bootleq
bootleq / gist:541723
Created August 21, 2010 03:36
[.vimrc] toggle between CamelCased/under_scored word
" TODO when no keyword is under/after the cursor, try looking backward to find a word.
fun! WordTransform()
let w = expand("<cword>")
let x = ''
let c = strpart(getline('.'), col('.') - 1, 1)
if match(w, '_') > -1
let x = substitute(w, '_\([a-z]\)', '\u\1', 'g')
else
let x = substitute(w, '\C[A-Z]', '_\L\0', 'g')
endif
@bootleq
bootleq / bootleg.vim
Created August 22, 2010 11:00
Gist stopped. For new version, see https://github.com/bootleq/vim-color-bootleg
" Vim color file
" Maintainer: bootleq <bootleq@gmail.com>
" Last Change: 2010-09-17
" Version: 0.2
"
" Summary:
" Modified from "slate" theme in 256 color term.
" Dark background, high contrast, similar color in cterm/gui, and avoid bold attribute in gui.
"
" Test:
command! -bang -nargs=* JsCompress call JsCompress(<bang>0, <f-args>)
" @param boolean save 0: save to temp file and return compressed content.
" 1: save with alternative filename, return the new name.
" @param boolean interact 1 to prompt before starting compression.
" @param string options extra options for running the compiler.
fun! JsCompress(save, ...)
let jar = '/scripts/google-compiler-20100616.jar'
let defaults = ' --compilation_level=SIMPLE_OPTIMIZATIONS'
\ . ' --warning_level=QUIET'
let input = expand('%')
command! -nargs=* Bookmarklet call Bookmarklet(<f-args>)
fun! Bookmarklet(...)
let result = JsCompress(0, 0, '--compilation_level=WHITESPACE_ONLY')
if len(getqflist()) == 0 && strlen(result) > 0
let reuse_win = 0
for winnr in tabpagebuflist(tabpagenr())
if bufname(winnr) == '[Bookmarklet]'
exec winnr . 'wincmd w'
let reuse_win = winnr
endif
@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 / gist:675391
Created November 13, 2010 15:04
Add MooTools global variables to JSLint predef option.
predef: [
// for MooTools Core 1.3. Excluded of standard global objects and Slick.
"$", "$$", "typeOf", "instanceOf", "$A", "$H",
"Core", "Event", "Browser", "Class", "Chain", "Events", "Options",
"Element", "Fx", "Request", "Cookie", "JSON", "Swiff",
// for MooTools More 1.3
"More", "URI", "Hash", "Form", "OverText", "Drag", "Slider", "Sortables", "Assets", "Color",
"Group", "IframeShim", "HtmlTable", "Keyboard", "Mask", "Scroller", "Tips", "Spinner", "Locale",