Tuesday, October 26, 2010

Re: How could I remove one line from current buffer in my vimscript?

Thanks! It works well.

On 10/26/10, Tim Chase <vim@tim.thechases.com> wrote:
> On 10/26/2010 04:51 AM, H Xu wrote:
>> How could I remove one line from current buffer in my vimscript?
>
> Without knowing which line to remove, it's hard to give specific
> help, but you can use the Ex "d" command to delete the current
> line in vimscript, prefix it with a line-number if you know it,
> or use a pattern to find it.
>
> function! Del32()
> " delete the 32nd line in the file
> 32d
> endfunction
>
> function DelFoo()
> " start on line #1 and search forward
> " for "Foo" (note that this won't find
> " Foo on line #1, but you can preserve
> " 'wrapscan', set it, and start your
> " search from line "$" instead if you
> " want to find it in the first line.
> 1/Foo/d
> endfunction
>
> -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