Skip to content

Instantly share code, notes, and snippets.

View mhinz's full-sized avatar

Marco Hinz mhinz

View GitHub Profile
autocmd VimEnter * nested
\ if argc() == 0
\| let last = filter(filter(copy(v:oldfiles), 'match(v:val, getcwd()) == 0'), 'filereadable(v:val)')
\| if !empty(last)
\| execute 'edit' fnameescape(last[0])
\| endif
\| endif
"
" usage: :Vimgrep /foo/ **
"
function! s:exit_handler(id) dict abort
execute 'cfile' self.tempfile
copen
endfunction
function! s:vimgrep(args) abort

Either in init.vim:

lua require 'colorizer'.setup()
lua << EOF
require 'colorizer'.setup {
  '*'; -- Highlight all files, but customize some others.
  css = { rgb_fn = true; }; -- Enable parsing rgb(...) functions in css.
function! RandNum() abort
return str2nr(matchstr(reltimestr(reltime()), '\.\zs\d*'))
endfunction
function! RandChar() abort
return nr2char((RandNum() % 93) + 33)
endfunction
function! Password() abort
return join(map(range(8), 'RandChar()'), '')
@mhinz
mhinz / foo.vim
Last active February 29, 2020 19:36
augroup grepper-side
autocmd!
autocmd FileType GrepperSide silent! keeppatterns %s/^\ze[^\>]/ / | 1
augroup END
function! s:context_jump(close_window)
let fileline = search('\v^\>\>\> [[:alnum:]\/\-_.~]+:\d+', 'bcn')
if empty(fileline)
return
endif
@mhinz
mhinz / day5.exs
Last active December 5, 2019 22:24
#!/usr/bin/env elixir
defmodule Day5 do
def run(), do: run(mem(), 0)
defp run(mem, ip) do
ins = parse_instruction(mem[ip])
a1 = if ins[:m1] == 1, do: ip+1, else: mem[ip+1]
a2 = if ins[:m2] == 1, do: ip+2, else: mem[ip+2]
a3 = if ins[:m3] == 1, do: ip+3, else: mem[ip+3]
function! g:FoldLispTopForm(lnum)
let curr = getline(a:lnum)
let next = getline(a:lnum+1)
if next[0] == '('
return 0
elseif curr[0] == '('
return 1
endif
return '='
endfunction
command! -nargs=* -range=% F
\ let lines = getline(<line1>, <line2>) |
\ enew |
\ call setline(1, lines) |
\ %!<args>
diff --git i/src/nvim/eval.c w/src/nvim/eval.c
index 28c590c0b..c60ec7b03 100644
--- i/src/nvim/eval.c
+++ w/src/nvim/eval.c
@@ -22538,3 +22538,50 @@ void ex_checkhealth(exarg_T *eap)
xfree(buf);
}
+
+/// Function given to ExpandGeneric() to obtain expansion specific
#!/usr/bin/env zsh
# Emulate Vim executable that simply returns its arguments.
> /tmp/vim.rb <<EOF
#!/usr/bin/env ruby
p ARGV
EOF
chmod 700 /tmp/vim.rb
VISUAL="/tmp/vim.rb -c 'first arg'"