Skip to content

Instantly share code, notes, and snippets.

View marcotrosi's full-sized avatar

Marco Trosi marcotrosi

View GitHub Profile
@marcotrosi
marcotrosi / Vim - Edit Register
Last active November 15, 2019 01:38
function and command to edit registers.
function! EditReg(reg)
let l:EditRegWinNum = bufwinnr("__EDITREG__")
if l:EditRegWinNum == -1
silent! belowright new __EDITREG__
setlocal modifiable
put! =getreg(a:reg)
$d_
setlocal noshowcmd
@marcotrosi
marcotrosi / completefunc.vim
Last active April 21, 2018 16:47
nested custom insert completion menus
let s:InitMenu = 'Font'
let s:NextMenu = ''
function! LatexFont(findstart, base)
if a:findstart
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~ '\a'
let start -= 1
endwhile
@marcotrosi
marcotrosi / panel.vim
Created July 12, 2017 04:46
this is a draft for a Vim plugin to keep my plugins in the "same" window
if exists('loaded_panel')
finish
endif
let loaded_panel = 1
" TODO maybe move configuration to .vimrc
" TODO when a width of 0 is given -> ask panel for size; introduce min/max width
let s:panels_config = { 'files':{'run':'Files', 'width':60},
\ 'buffers':{'run':'Buffers', 'width':20},
\ 'tags':{'run':'Tags', 'width':30},
#!/bin/bash
prog=$0
bash -l -c "$prog.sh"
#!/bin/bash
# extend PATH variable; dirty workaround for the audio extraction feature which requires ffmpeg
PATH=$PATH:/usr/local/bin
# save tool paths in variables
CocoaDialog='/Applications/cocoaDialog.app/Contents/MacOS/cocoaDialog'
YoutubeDL='/usr/local/bin/youtube-dl'
# get clipboard content
#!/bin/bash
# save tool paths in variables
CocoaDialog='/Applications/cocoaDialog.app/Contents/MacOS/cocoaDialog'
YoutubeDL='/usr/local/bin/youtube-dl'
# get clipboard content
Clipboard=$(pbpaste)
# run youtube-dl
#!/bin/bash
mkdir tmp.iconset
sips -z 16 16 $1 --out tmp.iconset/icon_16x16.png
sips -z 32 32 $1 --out tmp.iconset/icon_16x16@2x.png
sips -z 32 32 $1 --out tmp.iconset/icon_32x32.png
sips -z 64 64 $1 --out tmp.iconset/icon_32x32@2x.png
sips -z 128 128 $1 --out tmp.iconset/icon_128x128.png
sips -z 256 256 $1 --out tmp.iconset/icon_128x128@2x.png
sips -z 256 256 $1 --out tmp.iconset/icon_256x256.png
sips -z 512 512 $1 --out tmp.iconset/icon_256x256@2x.png
function! LaTeXMenu(modeprecmd)
let l:FontCmds = ["abort", "FontFamily", "FontSize"]
let l:c = 0
let l:c = confirm("LaTeX Menu","Font&Family\nFont&Size")
if l:c == 1
call FontFamily(a:modeprecmd)
endif
if l:c == 2
call FontSize(a:modeprecmd)
endif
function! MakeMenu()
let l:myMakeTargets = ["abort", "", "tags", "clean", "build", "test", "doc"]
let l:c = 0
let l:c = confirm("Make Menu","&make\nta&gs\n&clean\n&build\n&test\n&doc")
if l:c != 0
exe "make " . l:myMakeTargets[l:c]
endif
endfunction
nnoremap <leader>mm :call MakeMenu()<CR>
@marcotrosi
marcotrosi / log-minimal-demo.lua
Created July 8, 2015 08:22
Lua - automatic logging idea
-- load the log module
local log = require("log")
-- some function for demo
function add(a, b)
return a+b
end
-- wrap the main script in a main function
function main()