Vim’s concealcursor and conceallevel?

  question, vim

Problems encountered when using neosnippet
Well, the problem is this: when using neosnippet to expand a snippet, neosnippet will generate tabstop. these tabstops are hidden under the initialization plug-in code given by the author. the key to the problem is that if I expand a snippet, then immediately save and exit the file, and open the file again, I will find tabstop inserted into the text. this function makes me very depressed. this is the issue I submitted to the author on github.
The author also answered that this is a feature, but I finally asked him to ask me to look at it if tabstop was inserted into the text.

:help conceallevel
:help concealcursor

I have seen it, but I still don’t know how to solve the problem.

In fact, my problem is, if tabstop is not inserted into the text

The following figure shows tabstop when a snippet is expanded (I have cancelled the author’s recommended setting, so I can see tabstop)
Next, immediately exit the text and reopen it, and you will see tabstop inserted into the file.

That thing is a placeholder in the plug-in, please don’t call themtabstopBecausetabstopThere is a specific meaning in vim. When you say this, I didn’t understand what you said until I read it for half a day.

First of all, those placeholders are definitely useful. When you expand the code snippet, the placeholders help you determine the location of the code that needs to be filled in.Personally, I feel rather puzzled that you have already started a code fragment. Why do you close the file and open it without filling it out? What a wonderful operating habit!

However, there are still enough ways to deal with the exotic vim. The thing Shougo shows you is called in vimconceal (text), understood in Chinese as “hidden characters”. Those placeholders in Neosnippet are hidden characters. you can adjust whether/how hidden characters are presented.

Hidden characters are not really hidden. It is a special syntax in vim syntax. You can use syntax configuration commands to set the visual state of hidden characters, so if you find that the settings of hidden characters are not exactly the same as you think, then maybe the syntax (color matching) you are using has settings in this respect, you can change it or go in and have a look.

Let’s talk about the two options under normal circumstances:conceallevelAndconcealcursor.

When text is marked as “hidden characters”,conceallevelDetermines how this text is displayed, and it has four values:

  1. Set to0, not hidden, what to do or what to do (this is the default, so the placeholder is still visible)

  2. Set to1, each hidden character is replaced by a special character, which is set by the currently used syntax configuration. If syntax highlighting is not available, it is usedlistcharsIf there is no character set in the option, the default replacement character is a space.

  3. Set to2, let hidden characters completely hidden (meaning that even the default space is not needed), but if there is a setting in the syntax configuration to replace characters, use the setting of

  4. Set to3, hidden characters are not displayed at all, regardless of any settings.

So far, you may feel set to3Most refreshing, but you have to be careful.Not showing hidden characters at all means that once some plug-ins set hidden characters for you on their own initiative, you will never see them!For example, I once used a JSON syntax highlighting plug-in, and I don’t know what the author thinks. He put all the;They are all set as hidden characters, which makes me wonder for a long time.

If you must not show hidden characters at all, then you should at least consider how to match them.concealcursorTo use. By default, vim does not take the hidden character of the current cursor line.conceallevelIn other words, no matter how you set it, the hidden characters on the current cursor line will be displayed.concealcursorDetermines whether hidden characters are displayed on the current cursor line in the four main vim modes (normal, insert, visible, command).

To add: For command mode, the current cursor line refers to the highlighted matching position during search.

This option is empty by default, so in the four modes, hidden characters will be displayed on the current cursor line. You can use then i v cChoose a combination of the four values to set the way you want. Let’s take your example, for example, if you want me to not see these placeholders (hidden characters) for the rest of the time except for the insertion mode, thenset concealcursor='nvc'. If you know these code fragments like the back of your hand, it doesn’t matter if you don’t show hidden characters in insert mode.

By the way, you can try itUltiSnips, this plug-in is simpler than NeoSnippets, and is fully compatible with NeoSnippets code snippets, which is quite suitable for beginners (the function is definitely not bad).