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
" Tabularize mappings | |
" | |
" sa= -- align by equals | |
" sa> -- align by "=>" | |
" | |
" and so on. Note that any character can be entered and the mappings will | |
" attempt to align by that, in the simplest way possible. | |
" | |
" sa| -- equivalent to ":Tab/|" | |
" |
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
# So you can do something like: | |
# | |
# Post.some_scope =~ [some_post, some_other_post] | |
# | |
# Matching the results of the scope without caring about the order. | |
# | |
RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::MatchArray) |
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
" Whenever you execute an `:edit somefile` command with the cursor in the | |
" NERDTree, the file gets edited in the NERDTree buffer, which is usually not | |
" something you want. This autocommand attempts to edit the given file in the | |
" closest non-NERDTree buffer instead. | |
" | |
" It's fairly hacky, but seems to work. I'll probably use it myself, so I'll | |
" try to remember to update it if I find any problems. | |
augroup AvoidEditingNERDTree | |
autocmd! |
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
set viminfo+=! | |
if !exists('g:BOOKMARKS') | |
let g:BOOKMARKS = {} | |
endif | |
" Add the current [filename, cursor position] in g:BOOKMARKS under the given | |
" name | |
command! -nargs=1 Bookmark call s:Bookmark(<f-args>) | |
function! s:Bookmark(name) |
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
" Place in ftplugin/qf.vim | |
xnoremap <buffer> d :DeleteLines<cr> | |
nnoremap <buffer> dd :DeleteLines<cr> | |
nnoremap <buffer> u :UndoDelete<cr> | |
if !exists(':DeleteLines') | |
let b:deletion_stack = [] | |
" Delete by a pattern (with undo placing them all on top): |
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
command! -nargs=1 -complete=custom,s:TabjCompletion Tabj call s:Tabj(<f-args>) | |
function! s:Tabj(name) | |
for i in range(tabpagenr('$')) | |
let tabnr = i + 1 | |
for bufnr in tabpagebuflist(tabnr) | |
if stridx(bufname(bufnr), a:name) >= 0 | |
exe 'tabnext '.tabnr | |
while bufnr('%') != bufnr |
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
command! -nargs=1 StoreUndo call s:StoreUndo(<f-args>) | |
command! -nargs=1 -complete=custom,s:CompleteUndoStates RestoreUndo call s:RestoreUndo(<f-args>) | |
function! s:StoreUndo(label) | |
if !exists('b:stored_undo_state') | |
let b:stored_undo_state = {} | |
endif | |
let b:stored_undo_state[a:label] = undotree()['seq_cur'] | |
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
" Usage: | |
" | |
" :Ginitpull [remote-name] [branch-name] | |
" | |
" Initiates a github pull request in the default browser, from the given | |
" branch name to master, on the given remote. Tab-completes both arguments. | |
" | |
" If called without any arguments, defaults to the "origin" remote and the | |
" current branch name, which is probably what you usually want. | |
" |
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
" <space>x -> :X | |
" For easier typing of custom commands | |
nnoremap <space> :call <SID>SpaceMapping(0)<cr> | |
xnoremap <space> :<c-u>call <SID>SpaceMapping(1)<cr> | |
function! s:SpaceMapping(visual) | |
echo | |
let c = nr2char(getchar()) | |
if a:visual | |
normal! gv | |
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
#! /bin/sh | |
current_color='' | |
last_color='' | |
while :; | |
do | |
current_color=`curl -s 'http://api.thingspeak.com/channels/1417/field/1/last.txt'` | |
if [ "$current_color" != "$last_color" ] |