In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the linux Vim editor compatibility mode example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
Currently, in our tutorial on Vim, we discussed the Modeline functionality of the editor and how to extend the feature set of Vim with plug-ins. But as we know, Vim provides a lot of built-in functionality: so in this tutorial, let's go a step further and talk about the modes available when the editor starts.
But before we begin, please note that all the examples, commands, and instructions mentioned in this tutorial are tested on Ubuntu 14.04. we tested version 7.4 of Vim.
Compatibility Mode and incompatibility Mode in Vim
In order to better understand the above Vim schema, you need to understand an important aspect of the editor initialization process.
System-level and local vimrc files
When Vim starts, the editor searches for a system-wide vimrc file for system-wide default initialization.
This file is usually under the path of $VIM/vimrc on your system, and if it's not there, you can find its correct location by running the: version command in Vim. For example, in my case, the output of the relevant part of this command is as follows:
......... System vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~ / .vim / vimrc" user exrc file: "$HOME/.exrc" fall-back for $VIM: "/ usr/share/vim".
You can see that the system vimrc file is indeed located in $VIM/vimrc, but I checked that the $VIM environment variable has not been set on my machine. So in this example-as you can see in the output above-$VIM in my path is / usr/share/vim, which is a falling value (LCTT). So I tried to find vimrc in this path, and I saw that the file existed. This is my system vimrc file, as mentioned earlier-it is read when Vim starts.
After the system-level vimrc file is read and parsed, the editor looks for a user-specific (or local) vimrc file. The search order for this local vimrc is: environment variable VIMINIT, $HOME/.vimrc, environment variable EXINIT, and a file called exrc. Typically, there is a file such as $HOME/.vimrc or ~ / .vimrc, which can be thought of as a local vimrc.
What compatibility are we talking about?
Just as we talk about the compatibility mode and incompatibility mode of Vim, it is also worth knowing what compatibility will be achieved if these modes are turned on and off. To understand this, you need to know that Vim is an abbreviation for VIMproved, and as the full name implies, the Vim editor is an improved version of the Vi editor.
The improvement means that Vim's feature set is larger than Vi's. To better understand the difference between the two editors, click here.
When talking about Vim compatibility and incompatibility modes, we mean Vim compatibility Vi. When running in compatibility mode, most of the enhancements and improvements to Vim are not available. In any case, keep in mind that in this mode, Vim is not simply equivalent to Vi-this mode just sets some default options similar to the way Vi editors work.
The incompatibility mode-needless to say-makes Vim incompatible with Vi and allows users to use all its enhancements, improvements, and features.
How do I enable / disable these modes?
Try running the: help compatible command in Vim, and then you will see the following syntax:
'compatible'' cp' boolean (enabled by default, closed when | vimrc | or | gvimrc | exists)
The description says that compatibility mode is on by default, but it is closed when the vimrc file exists. But what kind of vimrc file are you talking about? The answer is local vimrc. Take a closer look: the details given by the help compatible command, you will find that the following is more clearly stated:
In fact, this means that when a | vimrc | or | gvimrc | file exists, Vim will use the default Vim, otherwise it will use the Vi default. (note: this will not happen if the system-level vimrc or gvimrc file contains the parameter "- u |".) .
So when Vim starts, the actual action is to parse the system vimrc file first-at this point it is in compatibility mode turned on by default. Now, whenever a user (or becomes a local) vimrc is found, the incompatible mode is turned on. The help compatible-default command makes it very clear:
The 'compatible' option is turned on when Vim starts. This will be applied when Vim initializes. But once a user-level vimrc file is found later, or there is a vimrc file in the current directory, or the VIMINIT environment variable is set, Vim will be set to incompatible mode.
If you want to ignore the default behavior and turn on incompatible mode when the editor starts parsing system vimrc files, you can do this by adding the following command to the beginning of that file.
: set nocompatible
Other useful details
Here are some more useful details about these patterns:
Now setting or resetting compatibility by creating a .vimrc file has a side effect: (keyboard) mapping (Mapping) conflicts when interpreting. This can have an impact when using conditions such as carriage return controls. If the mapping relationship depends on a specific value of compatibility, set or reset the mapping before giving it.
The above behavior can be overridden in the following ways:
If the-N command line argument is given, 'incompatible mode' is enabled even if the vimrc file does not exist.
If the-C command line argument is given, 'compatibility mode' is enabled even if a vimrc file exists.
If the-u {vimrc} parameter is applied, compatibility mode will be enabled.
When the name of Vim's executable ends with ex, the effect is the same as giving the-C parameter: even if there is a vimrc file, 'compatibility mode' is enabled, because when Vim is enabled with the name "ex", it makes Vim work like a "predecessor." (meaning Vim works like Vi). `
The above is all the content of the article "sample Analysis of Vim Editor compatibility modes in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.