Is there a way to check the type of a variable in vim? I need to check to make sure my functions argument is a number and am not sure how to go about it.
b: local to the current buffer. l: local to a function. g: global. :help internal-variables. Follow this answer to receive notifications.
Try out echo by running the following command: :echo "Hello, world!" You should see Hello, world! appear at the bottom of the window.
Vim script (aka Vimscript, or VimL) is a full feature scripting language, meaning it can solve almost any text processing problem.
Comments in Vimscript start with " (a double quote), not // . If you want to execute a normal mode command, like % or dd , you can use normal! % or normal! dd .
You're looking for type(varname)
.
Note that explicit type checks are somewhat of a code smell (especially because the exact implicit type conversions done by Vim are not widely known); though I have to admit that sometimes they do make for a nice and short function interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With