This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
augroup Test | |
au! | |
au CursorHold * call append(0, 'apetito') | |
au VimEnter * augroup Test|exec 'au!'|augroup END|augroup! Test | |
augroup END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! TPArchive2() | |
s/^/\t/ | |
.write >> ~/SimpleText/september_log2.taskpaper | |
d | |
endfunction | |
function! TPArchive() | |
g/.*@[Dd]one([0-9\-]\+)$/call TPArchive2() | |
endfunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Name of syntax item under the cursor | |
nore <leader>n :echo synIDattr(synID(line("."), col("."), 1), "name")<CR> | |
" Syntax stack of item under the cursor | |
nnore <leader>s :<C-U>echo join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), ' => ')<CR> | |
" Color of syntax item under the cursor | |
echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Count matches in a string. | |
function! s:count(str, pat) | |
let cnt = 1 | |
let index = matchend(a:str, a:pat) | |
while index >= 0 | |
let cnt += 1 | |
let index = matchend(a:str, a:pat, index) | |
endwhile | |
return cnt - 1 | |
endfunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! QFWinInTab(tabnr) "{{{ | |
return len(filter(range(1, winnr('$')), 'gettabwinvar('.a:tabnr.', v:val, "&buftype") == "quickfix"')) | |
endfunction "QFWinInTab }}} | |
function! HasQF() "{{{ | |
return len(filter(range(1, tabpagenr('$')), 'QFWinInTab(v:val)')) | |
endfunction "HasQF }}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Switch both sides around a 'pivot'. | |
" e.g.: let's say we have this string | |
" abc && def | |
" put the cursor on 'a' then vf&<leader>ssff | |
" That will yield: | |
" def && abc | |
function! Swap(...) "{{{ | |
let start_v = col("'<") | |
let end_v = col("'>") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:ScourgeWhitespace(flag) | |
if a:flag | |
echo "Killing whitespace with fire..." | |
%s/ \+$// | |
else | |
echo "Gently helping you to remove whitespace..." | |
%s/ \+$//c | |
endif | |
endfunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if &readonly | |
nnoremap <silent><buffer> <Esc> :quit<CR> | |
nnoremap <silent><buffer> <CR> <C-]> | |
nnoremap <silent><buffer> <BS> <C-O> | |
nnoremap <silent><buffer> <Down> :call search('\(''\<bar><bar>\)[^, <bar>]\{-1,}\1', 'W')<CR> | |
nnoremap <silent><buffer> <Up> :call search('\(''\<bar><bar>\)[^, <bar>]\{-1,}\1', 'Wb')<CR> | |
endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Our private history. | |
let s:history = exists('s:history') ? s:history : [] | |
function! LiteralSearch() | |
" First, empty the input history. | |
call histdel('input') | |
" next, add our own history. | |
call map(copy(s:history), 'histadd("input", v:val)') | |
" Get user's input. | |
let input = input('g/') | |
if empty(input) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! TransposeWords(...) range | |
" if no arg was provided use the count. | |
let cnt = a:0 ? a:1 : v:count1 | |
let cur = getpos('.') | |
let pos = searchpos('\%#.', 'wcn') | |
if matchstr(getline(line('.'))[(col('.') - 1) :], '^.') =~ '\w' | |
\ && col('.') != col('$') | |
let pat = '\(\w*\%#\w\+\)\(\_W\+' | |
\ . repeat('\w\+\_W\+', cnt - 1) | |
\ . '\)\(\w\+\)' |