Saturday, April 30, 2011

Re: determine if a certain line occurs in a file

Hi cyboman!

On Sa, 30 Apr 2011, cyboman wrote:

> the problem that i'm facing right now is if the pattern is not in the
> file, i get an error message, E486: Pattern not found Copyright 2010,
> Company E. is there a way to tell vim not to execute the command if
> pattern is not found, say something like:
>
> function UpdateCopyrightYear()
> let l:cmd = 's/\(\d\+\)/\1-'.strftime("%Y").'/'
> if g/Copyright 2010, Company E/

if search('Copyright 2010, Company E', 'n')

> g/Copyright 2010, Company E/exec l:cmd
> endif
> endfunction

regards,
Christian

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