Tuesday, May 31, 2011

Re: Vim scripts: insert new line staying with normal mode

On 05/31/2011 08:33 AM, Steven Lee wrote:
> I attempt to write a function implementing insert new line which
> filled consecutive '=' :
>
> How can I correct above scripts?

While it diverges from your original script, I'd go for something
more readable like:

:nnoremap <f4> :put=repeat('-',len)<cr>

which makes more sense to me.

I've occasionally used an "underline this" sequence of commands
to make the underline the same length as the line I'm currently on:

:nnoremap <f4> :t.|s/./-/g<cr>

This copies the current line below itself and replaces each
character with a "-" to create the underline. As an aside, that
formula works nicely with a :g command to underline all my
chapter headings:

:g/^CHAPTER/t.|s/./-/g

Hope this makes it easier for you. I believe the "norm" command
does odd things with escape characters, and escaping
escape-characters.

-tim


--
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:

Post a Comment