Update vimscript.md (#2008)

Added a section on overwriting functions
This commit is contained in:
Sweidan Omár 2023-07-20 13:05:28 +02:00 committed by GitHub
parent 9c2b6d725f
commit 3b16d4cf2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -146,6 +146,20 @@ endfunction
See: [Functions](http://learnvimscriptthehardway.stevelosh.com/chapters/23.html)
### Overwriting
```vim
function f1()
echo "f1"
endfunction
function! f1()
echo "f1 overridden"
endfunction
```
If you define two functions with the same name, Vim will throw an error complaining that the function `f1` already exists. To overwrite the previous function with the same name, add a `!` after the function keyword.
### Namespacing
```vim