From 5f2532e1e377b2fd99c3f0b0e2b5d0cc424f97dd Mon Sep 17 00:00:00 2001 From: hophacker Date: Sun, 14 Jul 2019 14:52:01 +0800 Subject: [PATCH] add new shortcut tt => ToggleRspecTest(), which toggles now: true of a spec test --- vim/settings/yadr-keymap.vim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vim/settings/yadr-keymap.vim b/vim/settings/yadr-keymap.vim index 961745c..4353704 100644 --- a/vim/settings/yadr-keymap.vim +++ b/vim/settings/yadr-keymap.vim @@ -304,5 +304,15 @@ function! TogglePaste() endif endfunction +function! ToggleRspecTest() + let l:line=getline('.') + if l:line =~? ',\s*now:\s.*true' + call setline('.', substitute(l:line, "\,\\s*now:\\s*true", "", "")) + else + call setline('.', substitute(l:line, "\\(['\"]\\)\\s*do", "\\1, now: true do", "")) + endif +endfunction + " set paste -nnoremap p :call TogglePaste() +nnoremap tp :call TogglePaste() +nnoremap tt :call ToggleRspecTest()