Tuesday, May 31, 2011

Vim scripts: insert new line staying with normal mode

Hi all,

It sounds like some vim users have asked similar question, but not
exactly what I want.

I attempt to write a function implementing insert new line which
filled consecutive '=' :

let len = 5
let @x = '='
exe 'normal! ' . 'o\\<Esc\\>0' . '"x' . len . 'p'

My solution is below:
1. o -- enter new line below current line
2. <Esc> -- go back to normal mode
3. 0 -- go to head of line
4. "x5p -- copy 5 times using register x value, i.e. '='

But with step 2, it did not work as I thought. It did not go back to
normal mode.

How can I correct above scripts?

Thanks,
Steven.l

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: