On 5/16/07, Charles E Campbell Jr <[EMAIL PROTECTED]> wrote:
fREW wrote:

> Hey everyone,
>
> How do I have a function call Normal commands?  Example: I'd like to
> make a function that will open a certain file, and then set the
> foldlevel to 1, and then go to the right window.  So I have:
>
> function TodoListMode()
>  execute ":e ~/.todo.otl"
>  execute ":Calendar"
> endfunction
>
> and then after the second command I want to do:
> <ctrl>wl
> zM
> zr

* may I point out that you're using "execute" when you don't need to.
* you're already in ex mode; no need to use colons to do ex mode commands
* ctrl-w_l can be performed with wincmd l .
* to perform normal mode commands in a function, use norm! (the
exclamation prevents any maps from interfering)

So, with these points in mind:

fun! TodoListMode()
  e ~/.todo.otl
  wincmd l
  norm! zMzr
  Calendar
endfun

Now, I confess that I didn't test this...

Regards,
Chip Campbell



Thanks for the pointers!

I ended up with this, which doesn't use any normal commands at all ironically.


function! TodoListMode()
 e ~/.todo.otl
 Calendar
 wincmd l
 set foldlevel=1
endfunction

Thanks for the help though, it works just as one would hope now!

-fREW

Reply via email to