I'm working on creating a function that will:
- Inspect the current file I'm working on
- Create a new buffer in my test directory based on my file name
- Edit that file and start my snipmate "test" template
So far I have everything working except triggering snipmate. What I'd like to do is insert a <Tab>
character like I was in insert mode to trigger snipmate to kick off
" Only works for modules and models right now
function! MakeTest()
" sub out any prefix
let base_test_path = substitute(expand('%:r'), '\(lib/\|app/models/\)', '', 'g')
execute 'edit ' . 'test/unit/' . base_test_path . '_test.rb'
norm i test<Tab>
endfunction
Instead it is literally mapping to test<Tab>
into my template. My guess is that I don't want to use norm
for this, but I'm not too keen on what I should use instead.
Any thoughts?
Is there a way to enter insert mode from a function?