Skip to content

Instantly share code, notes, and snippets.

View Raimondi's full-sized avatar

Israel Chauca Fuentes Raimondi

View GitHub Profile
@Raimondi
Raimondi / test_vimrc
Created October 18, 2013 17:03
Start vim with vim -N -u test_vimrc
let &rtp = expand('<sfile>:p:h') . ',' . &rtp . ',' . expand('<sfile>:p:h') . '/after'
set bs=2
function! CleanScreen()
if &go ~=# 'm'
" Set options for clean screen.
else
" Set options back to normal.
endif
endfunction
nore <F2> :<C-U>call CleanScreen()<CR>
@Raimondi
Raimondi / gist:6750062
Last active December 24, 2015 05:19 — forked from introom/gist:6750033
" Toggle Comment
augroup toggle_comment
au FileType vim let b:comment_leader = '" '
au FileType c,cpp,java let b:comment_leader = '// '
au FileType sh,make,python let b:comment_leader = '# '
au FileType text let b:comment_leader = '% '
augroup END
function! ToggleComment() range
let cl = b:comment_leader;
for linenr in range(a:firstline, a:lastline)
@Raimondi
Raimondi / range_search.vim
Created June 7, 2013 01:34
Restrict search to given range.
comm! -range=% -nargs=* RSearch /\%(\%><line1>l\%<<line2>l\)\&\%(<args>\)
func! Inc(...)
if a:0
let g:inc = 0
else
let g:inc += 1
endif
return g:inc
endf
call Inc(1)
%s/regex/\=Inc()/
normal! ggdG
Let lines = ["# Please wait for prove to run...",
\"# Files:"]
let lines = lines + map(split(l:files, '\v\s'), '"# * " . v:val')
call setline(1, lines)
@Raimondi
Raimondi / tabmappings.vim
Created October 12, 2012 06:09
Tab mappings
function! TabMappings()
if &ft == 'c'
return "\<C-X>\<C-U>"
elseif &ft == 'c++'
return "\<C-X>\<C-U>"
elseif &ft == 'objc'
return "\<C-X>\<C-U>"
elseif &ft == 'objcpp'
return "\<C-X>\<C-U>"
elseif neocomplcache#sources#snippets_complete#expandable()
@Raimondi
Raimondi / split_list.vim
Created September 13, 2012 09:06
Split lists
" bairui's code, just too good to let it pass.
function! SplitListByCount(list, count)
return map(filter(range(len(a:list)), 'v:val % '.a:count.' == 0'),
\ 'a:list[v:val : v:val + a:count - 1]')
endfunction
function! SplitListInNPieces(list, number)
let ratio = len(a:list)/a:number
return !empty(a:list) && len(a:list) % a:number == 0
\ ? map(range(a:number),
@Raimondi
Raimondi / recursive.vim
Created August 11, 2012 07:57
Vim - Recursive functions.
function! Count(s, e)
let s = type(a:s) == type({}) ? values(a:s) : a:s
let ccount = 0
for i in s
if type(i) != type([]) && type(i) != type({})
let ccount += (type(i) == type(a:e) && i == a:e) ? 1 : 0
else
let ccount += Count(i, a:e)
endif
unlet i
@Raimondi
Raimondi / glob_files_2_tags.vim
Created August 4, 2012 18:26
vim: Add all tag-files in a dir to &tags
" Append evey file to the 'tags' option.
for f in glob('~/path/to/tags-dir/lib*.tags', 1, 1)
let &tags .= ','.f
endfor