Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does Vimscript mean?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the meaning of Vimscript, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

Vim's scripting language, called Vimscript, is a typical dynamic imperative language, which provides most common language features: variables, expressions, control structures, built-in functions, user-defined functions, first-level strings, advanced data structures (lists and dictionaries), terminals and files, regular expression pattern matching, exceptions, and integrated debuggers.

If you want to read the Vimscript documents that come with Vim through the built-in help system, enter the following within any Vim session:

: help vim-script-intro

You first came into contact with the Vim script in the vimrc file. When Vim starts, it will read the contents of the file.

And execute the commands in it. You can set options in it. You can also use any colon command in it to

Commands that begin with ":"; these commands are sometimes referred to as Ex commands or command-line commands. Syntax files are actually Vim scripts. The same is true for files that set options for a particular file type. One

Complex macros can be defined separately in a Vim script file. You can think of other applications for yourself. Let's start with a simple example:

: let I = 1

: while i

< 5 : echo "count is" i : let i += 1 :endwhile备注:那些 ":" 字符并非必须。只有在你键入命令时才需要,在编写 Vim 脚本时可以去掉。在这里用一是为了清楚,二是为了区别于普通模式命令。 备注:你可以拷贝这里的示例文本,然后用 :@" 执行。本例的输出是: count is 1 count is 2 count is 3 count is 4

The ": let" command on the first line assigns a value to a variable. The common usage is:

: let {variable} = {expression} in the example the variable name is "I" and the expression is a simple numeric value of 1.

The ": while" command starts a loop. The common usage is:

: while {condition}: {statement}

Endwhile as long as the condition is true, "while" and

Statements surrounded by ": endwhile" are executed. The condition used in the example is the expression "I < 5". This condition is always true when the variable I is less than 05:00.

Note: if you happen to write an endless loop statement, you can use CTRL-C to terminate it in the

Use CTRL-Break on MS-Windows). The ": echo" command displays its parameters. The parameters in this example are the string "count is" and variables

The value of I. Because the value of I is 1 at the beginning, it will display:

Count is 1 is followed by the ": let I + = 1" command.

This command is equivalent to ": let I = I + 1". Add the new value to the variable I and assign it to the same variable. This example is given to explain the command, but if you really want to write such a loop, the following expression is more concise:

: for i in range (1,4)

: echo "count is" I

Endfor: thank you for reading this article carefully. I hope the article "what is the meaning of Vimscript" shared by the editor will be helpful to everyone? at the same time, I also hope that you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report