Skip to content

Instantly share code, notes, and snippets.

@dahu
dahu / roman_forth.rebol
Created October 6, 2016 10:42
Roman numerals in non-idiomatic Rebol
Rebol [
Title: "Roman Numbers"
Source: "Thinking in Forth (Ans, 2004) by Leo Brodie, Figure 4.9, Page 153"
]
romans: [I V X L C D M]
col: 0
ones: does [col: 1]
tens: does [col: 3]
hundreds: does [col: 5]
thousands: does [col: 7]
Some may be more advanced than others, and some are vi only...
Vim Tutorials
=============
* http://blog.smr.co.in/linux/advanced-vim-tutorial/
* http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
* http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-advanced-tutorial-videos/
* http://linuxgazette.net/152/srinivasan.html
* http://www.eng.hawaii.edu/Tutor/vi.html
@dahu
dahu / gist:8625214
Created January 25, 2014 23:12
~/.vim/ftplugin/help.vim
" help.vim - ftplugin for better Help navigation and operation
" Barry Arthur
" jump to links with CR
nmap <buffer> <CR> <C-]>
" jump back with BS
nmap <buffer> <BS> <C-T>
" skip to next option link
nmap <buffer> o /'[a-z]\{2,\}'<CR>
" skip to previous option link
@dahu
dahu / gist:8532082
Created January 21, 2014 00:22
bairui learns a zsh or two; thanks osse :-)
2014-01-21 07:25:27 bairui here
2014-01-21 07:25:53 bairui i'm looking at your vdwrap script and i have some questions
2014-01-21 07:26:13 osse uh-oh
2014-01-21 07:26:24 bairui no, it's my lack of zsh i'm focusing on here
2014-01-21 07:26:35 bairui break this down for me: cd ${1%%/left*}
2014-01-21 07:28:14 osse you may proceed
2014-01-21 07:28:20 bairui i did :)
2014-01-21 07:28:47 bairui break this down for me: cd ${1%%/left*}
2014-01-21 07:30:23 osse hee hee, funny you should pick about the only thing that is valid on posix sh :P
2014-01-21 07:30:54 osse ${foo%text} expands the variable foo with 'text' removed from the end of the expanded value
@dahu
dahu / finding-vim-help.md
Last active January 3, 2016 10:19
Vim's Ladder

Take the following steps to get the Vim help you need:

  • If you're having trouble with a plugin, read its README first to make sure you have installed any dependencies and configured it correctly.

  • :help topic <= will jump to topic within the manual.

  • :helpgrep pattern <= will search for all occurrences of pattern throughout the manual.

Use :cope to open the quickfix window of search results.

@dahu
dahu / gist:8382926
Last active January 3, 2016 00:29
coffeescriptish function definitions in vim
let fn_idx = 0
let fn_var = {}
function! ExpandFvars(fname, elem)
let e = a:elem
if e =~ 'vlet '
let [var, val] = matchlist(e, '\(\w\+\)\s*=\s*\(\w\+\)')[1:2]
let g:fn_var[a:fname][var] = get(g:fn_var[a:fname], var, val)
let e = ''
else
@dahu
dahu / gist:5865766
Last active December 18, 2015 23:59
indented-siblings text-object for vim
" indented-siblings text-object
" Barry Arthur 26 Jun 2013
if !exists('g:indented_siblings_include_blank_lines')
let g:indented_siblings_include_blank_lines = 0
endif
function! s:crawl_indent(indent, line, direction)
let range = a:line
let direction = a:direction > 0 ? 1 : -1
@dahu
dahu / gist:5793544
Created June 16, 2013 21:41
:[range]normal! operator-func for Vim
" :[range]normal!
" Barry Arthur 2013-06-17
nmap <silent> <leader>n :set opfunc=Normal<CR>:call feedkeys('g@')<cr>
vmap <silent> <leader>n :<C-U>call Normal(visualmode(), 1)<CR>
function! Normal(...)
if a:0 == 2 " Invoked from Visual mode, use '< and '> marks.
call feedkeys(":" . line("'<") . ',' . line("'>") . "normal! ")
else " Standard &opfunc mode, use '[ and '] marks.
@dahu
dahu / gist:5770281
Created June 13, 2013 00:24
retain buffer position after FufBuffer call
function! Foo()
echom "Foo"
if exists('b:fuf')
echom "fuffed!"
normal! 'a
unlet b:fuf
endif
endfunction
augroup FufPlay
@dahu
dahu / gist:5695125
Created June 2, 2013 22:01
Match Current Sexp - an alternative approach
" Alternative approach to current sexp highlighting
" Barry Arthur 2013-06-03
let b:sexp_match = -1
function! MatchInnerSexp()
let pos = getpos('.')
let save_reg = @*
if mode() !~# 'v'
normal! va(