This function can be used to separate filenames from paths, without
the need for regular expression craziness.
:help fnamemodify()
:help filename-modifiers
On Feb 17, 10:30 am, Alessandro Antonello <antonello....@gmail.com>
wrote:
> Hi, thank you all.
>
> Off course. I was so ansious to finish the function that I didn't notice this
> fault.
>
> Thank you all guys,
> Alessandro Antonello
>
> 2011/2/17 Benjamin R. Haskell <v...@benizi.com>:
>
>
>
> > On Thu, 17 Feb 2011, Alessandro Antonello wrote:
>
> >> Hi, all.
>
> >> I'm trying to build a function that separates file names from full paths.
> >> I was using matchstr() function but there is a problem. It doesn't return
> >> anything. For example:
>
> >> :echo matchstr("~/.vim/atpl/class.h", "/\w\+\.h$")
>
> > The problem is with the backslashes inside double quotes being chewed up.
>
> > To see what's happening, do:
>
> > :echo "/\w\+\.h$"
> > echoes:
> > /w+.h$
>
> > So, the pattern you're matching against is slash, followed by one or more
> > w's, followed by any character ('.' without a backslash), ending with 'h'.
>
> > See:
>
> > :help usr_41 -- search for /double quote
> > :help expr-quote
>
> > To avoid the issue, it's generally easiest to use single quotes:
>
> > :echo matchstr('~/.vim/atpl/class.h', '/\w\+\.h$')
> > echoes:
> > /class.h
>
> > --
> > Best,
> > Ben
>
> > --
> > 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, visithttp://www.vim.org/maillist.php- Hide quoted text -
>
> - Show quoted text -
--
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