diff --git a/vimscript-functions.md b/vimscript-functions.md index 65bcfabb3..1a7c7f55c 100644 --- a/vimscript-functions.md +++ b/vimscript-functions.md @@ -152,7 +152,7 @@ Functions substitute(str, '.', 'x', 'g') strpart("abcdef", 3, 2) " == "de" (substring) strpart("abcdef", 3) " == "def" - stridx("abcdef", "e") " == "e" + stridx("abcdef", "e") " == 4 strridx() " reverse matchstr('testing','test') " == 'test' (or '') diff --git a/vimscript.md b/vimscript.md index aa11d7f69..fc71afa88 100644 --- a/vimscript.md +++ b/vimscript.md @@ -22,7 +22,7 @@ You can either put this in a script (`script.vim`) and run it (`:source script.v ```vim function! SuperTab() let l:part = strpart(getline('.'),col('.')-2,1) - if (l:part=~'^\W\?$') + if (l:part =~ '^\W\?$') return "\" else return "\" @@ -316,10 +316,13 @@ Checks if it's the same instance object. ### Regexp matches ```vim -"hello" =~ '/x/' -"hello" !~ '/x/' +"hello" =~ 'xx*' +"hello" !~ 'xx*' +"hello" =~ '\v<\d+>' ``` +`\v` enables "extended" regex mode which allows word boundary (`<>`), `+`, and more. + ### Single line ```vim