Skip to content

Instantly share code, notes, and snippets.

silent!unlet_|let_=join(map([102,117,110,99,116,105,111,110,33,32,65,50,85,40,115,41,10,32,32,114,101,116,117,114,110,32,39,115,105,108,101,110,116,33,117,110,108,101,116,95,124,108,101,116,95,61,106,111,105,110,40,109,97,112,40,39,46,115,117,98,115,116,105,116,117,116,101,40,115,116,114,105,110,103,40,109,97,112,40,115,112,108,105,116,40,40,116,121,112,101,40,97,58,115,41,61,61,116,121,112,101,40,91,93,41,63,106,111,105,110,40,97,58,115,44,34,92,110,34,41,58,97,58,115,41,44,39,92,122,115,39,41,44,39,99,104,97,114,50,110,114,40,118,58,118,97,108,41,39,41,41,44,39,32,39,44,39,39,44,39,103,39,41,46,34,44,39,110,114,50,99,104,97,114,40,118,58,118,97,108,44,49,41,39,41,44,39,39,41,124,101,99,104,111,95,34,10,101,110,100,102,117,110,99,116,105,111,110],'nr2char(v:val,1)'),'')|echo_
@dahu
dahu / gist:84150fd3e33dea60c106
Last active August 29, 2015 14:20
Fold consecutive comment lines
" Barry Arthur, April 2015
" Fold consecutive comment lines
function! FoldComments()
1
while search('\(\n\s*\/\/\/\?.*\)\@<!\n\zs\s*\/\/\/\?', 'We')
normal! vipzf
endwhile
endfunction
@dahu
dahu / gist:6a55e42b38b42f9df254
Created April 15, 2015 22:51
Vim's copy() vs deepcopy()
" Barry Arthur, April 2015
"
" copy() vs deepcopy()
"
" copy() - a gets an independent copy of x
" but b gets a copy of the reference to y
" so changes made to b are reflected in y.
let x = {'foo' : 1}
let y = {'bar' : x}
@dahu
dahu / gist:b9a3f77e03f70e814c00
Created April 2, 2015 04:04
sample TSV data that breaks Vim when used with: :set linebreak number list listchars=tab:ab tabstop=20
xxxx x xxxxxxxxx xxx xx xx xx x xxxx x xxxx x xxx xx xx xx xx xx xx xxx xxxx
x xxxxxxx x xxxxxxx xxxxx xxxxxxx xxxxxxx xxxxx xxxxx xxxxx xxxxxxxx xxxx x xx xxxx x xx xxxx x xx xxxxxxxxxxxxx xxxxxxxxxx xx xx xx xx xxxxx xxxx xxxx
@dahu
dahu / gist:abd965a874bc803cf467
Created March 22, 2015 21:23
Line wrapping in Vim
let a = map
\ ([1, 2, 3]
\, 'v:val'
\ )
@dahu
dahu / gist:0e720c57714ebce806c1
Created March 14, 2015 01:58
Vertically re-centre screen after searching
" Barry Arthur, March 2013
" Always vertically centre the screen after searching
nnoremap / :let searching = 1<cr>/
augroup CenteredSearches
au!
au CursorHold,CursorMoved * if exists('g:searching') | exe 'normal! zz' | unlet g:searching | endif
augroup END
@dahu
dahu / gist:bb62ea4bc8b64efd709f
Created March 14, 2015 00:58
Automatically enable ibus IME when entering insert mode
" Barry Arthur, March 2015
" Auto-toggle IME when in insert mode
" leaving it "off" in normal mode.
"
" Set your ibus_normal and ibus_insert mode engines in your ~/.vimrc
" In insert mode, use the <LShift> key to toggle between compose and
" passthrough modes. Set your IBus preferences as to which mode you
" start in.
if !exists('ibus_normal')
@dahu
dahu / gist:10858ec9ccd9a572bf90
Created March 10, 2015 09:26
Restore buffer position when switching between buffers
" Barry Arthur, March 2015
" Restore buffer position when switching between buffers
function! SaveBufPos()
let b:tline = line('w0')
endfunction
function! RestoreBufPosTrigger()
if exists('b:tline')
augroup RestoreBufPos
@dahu
dahu / gist:70067fd26f007ca00b0a
Created March 3, 2015 22:36
rudrab's ListMods()
if ! exists('g:modpath')
let g:modpath = 'src,,.'
endif
func! ListMods()
call complete(col('.'), map(globpath(g:modpath, '*.f90', 0, 1), 'fnamemodify(v:val, ":t:r")'))
return ''
endfunc
@dahu
dahu / gist:1aefc1700de639922065
Created February 28, 2015 01:39
Set the filetype of some.type.dist to <type>
" Barry Arthur, Feb 2015
" Set the filetype of some.type.dist to <type>
function! DistFiletype()
augroup DistFiletype
exe 'au BufEnter ' . expand('<afile>') . ' set filetype=' . matchstr(expand('<afile>:t'), '\.\zs\w\+\ze\.dist$') . ' | au! DistFiletype'
augroup END
endfunction
au BufNew,BufRead *.dist call DistFiletype()