OSDN Git Service

Regular updates
[twpd/master.git] / vimscript.md
index a4edc82..79c8e96 100644 (file)
@@ -3,7 +3,7 @@ title: Vim scripting
 category: Vim
 prism_languages: [vim]
 layout: 2017/sheet
-updated: 2017-08-30
+updated: 2020-07-05
 weight: -10
 tags: [Featurable]
 ---
@@ -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 "\<Tab>"
   else
       return "\<C-n>"
@@ -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