mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
correct vim9script syntax
This commit is contained in:
parent
8083755456
commit
bea8f291bc
@ -194,32 +194,23 @@ echo "0xA" + 1 # Number
|
|||||||
# Variables
|
# Variables
|
||||||
# ###########
|
# ###########
|
||||||
|
|
||||||
var b_my_var = 1 # Local to current buffer
|
var b:my_var = 1 # Local to current buffer
|
||||||
var w_my_var = 1 # Local to current window
|
var w:my_var = 1 # Local to current window
|
||||||
var t_my_var = 1 # Local to current tab page
|
var t:my_var = 1 # Local to current tab page
|
||||||
var g_my_var = 1 # Global variable
|
var g:my_var = 1 # Global variable
|
||||||
var l_my_var = 1 # Local to current function
|
|
||||||
var s_my_var = 1 # Local to current script file
|
|
||||||
var a_my_arg = 1 # Function argument
|
|
||||||
|
|
||||||
# The Vim scope is read-only
|
|
||||||
echo true # Special built-in Vim variables
|
|
||||||
|
|
||||||
# Access special Vim memory like variables
|
# Access special Vim memory like variables
|
||||||
var @a = 'Hello' # Register
|
var @a = 'Hello' # Register
|
||||||
var $PATH='' # Environment variable
|
var $PATH='' # Environment variable
|
||||||
var &textwidth = 79 # Option
|
var &textwidth = 79 # Option
|
||||||
var &l_textwidth = 79 # Local option
|
var &l:textwidth = 79 # Local option
|
||||||
var &g_textwidth = 79 # Global option
|
var &g:textwidth = 79 # Global option
|
||||||
|
|
||||||
# Access scopes as dictionaries
|
# Access scopes as dictionaries
|
||||||
echo b: # All buffer variables
|
echo b: # All buffer variables
|
||||||
echo w: # All window variables
|
echo w: # All window variables
|
||||||
echo t: # All tab page variables
|
echo t: # All tab page variables
|
||||||
echo g: # All global variables
|
echo g: # All global variables
|
||||||
echo l: # All local variables
|
|
||||||
echo s: # All script variables
|
|
||||||
echo a: # All function arguments
|
|
||||||
echo v: # All Vim variables
|
echo v: # All Vim variables
|
||||||
|
|
||||||
# Constant variables
|
# Constant variables
|
||||||
@ -227,7 +218,7 @@ const x = 10 # Constant
|
|||||||
|
|
||||||
# Function reference variables
|
# Function reference variables
|
||||||
var IsString = {x -> type(x) == type('')} # Global
|
var IsString = {x -> type(x) == type('')} # Global
|
||||||
var s_isNumber = {x -> type(x) == type(0)} # Local
|
var isNumber = {x -> type(x) == type(0)} # Local
|
||||||
|
|
||||||
# Multiple value binding
|
# Multiple value binding
|
||||||
var [x, y] = [1, 2]
|
var [x, y] = [1, 2]
|
||||||
@ -448,5 +439,5 @@ endif
|
|||||||
var g_loaded_my_plugin = true
|
var g_loaded_my_plugin = true
|
||||||
|
|
||||||
# Default values
|
# Default values
|
||||||
var s_greeting = get(g:, 'my_plugin_greeting', 'Hello')
|
var greeting = get(g:, 'my_plugin_greeting', 'Hello')
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user