Josh Moore
Josh Moore

Reputation: 13568

Execute autocommand in vim

I am using SimpleFold for folding vim. I mapped it to a key setting:

map <unique> <silent> <Leader>f <Plug>SimpleFold_Foldsearch

However, I would like to set it up as an auto command. I tried adding this line to my .vimrc file:

autocmd FileType ruby <Plug>SimpleFold_Foldsearch

But, I just get an error now when I open a ruby file. Can anybody help me setup the autocmd so that it works?

Upvotes: 1

Views: 1482

Answers (1)

ZyX
ZyX

Reputation: 53674

:autocmd is executing Ex mode commands, so your code is wrong. You should be using :normal or feedkeys():

autocmd FileType ruby :execute "normal \<Plug>SimpleFold_Foldsearch"

Upvotes: 5

Related Questions