>     if ( line ) {
>         if ( line =~ a:pattern ) {
>         # do something
>         }
>         else {
>         # do something else
>         }
>     }
> }
> endfun
> 
> FindPattern( '=>\\s?{' )
I feel like I'm breaking some rule by posting here without my name being some form of Mark. :)
No offence, but this code is riddled with syntax errors. You're using c like syntax instead of vimscript. Here's a cleaned up version:
function FindPattern( pattern )
   let line = getline('.')
   if ( line =~ a:pattern )
      " do something
   else
      " do something else
   endif
endfunction
"And the regex needs a little bit of work too:
call FindPattern( '=>\s\?{' )
I would probably use '=>\s*{' but either could work depending on the situation.
-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Monday, August 8, 2016
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment