Last active
December 14, 2015 00:49
-
-
Save lucascaton/5001446 to your computer and use it in GitHub Desktop.
Add this code to your ~/.vimrc.
This file contains 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
" RSpec focus | |
function! s:Preserve(command) | |
" Save cursor position | |
let l = line(".") | |
let c = col(".") | |
" Do the business | |
execute a:command | |
" Restore cursor position | |
call cursor(l, c) | |
" Remove search history pollution and restore last search | |
call histdel("search", -1) | |
let @/ = histget("search", -1) | |
endfunction | |
function! s:AddFocusTag() | |
call s:Preserve("normal! ^ / do\<cr>C, focus: true do\<esc>") | |
endfunction | |
function! s:RemoveAllFocusTags() | |
call s:Preserve("%s/, focus: true//e") | |
endfunction | |
command! -nargs=0 AddFocusTag call s:AddFocusTag() | |
command! -nargs=0 RemoveAllFocusTags call s:RemoveAllFocusTags() | |
:nnoremap <leader>t :AddFocusTag<CR> | |
:nnoremap <leader>r :RemoveAllFocusTags<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment