Let's say I have a latex file with a line

$\nabla_Y Z = \nabla_X Y$

If I set conceallevel=2 this becomes

 ∇_Y Z = ∇_X Y

which is nice. If I have my cursor on another line and want to change the Z I click on the Z which "unconceals" the line, so the cursor is on the b in the first \nabla.

Is there any way to make the cursor move to the Z when the line "unconceals"?

I definitely want this behavior for mouseclicks; I'm not sure if I want it for other movement between lines (e.g. with j or k).

I'm using Neovim 0.4.4

EDIT: It seems like neovim issue #5341 and PRs 5087 and 5822 are about this.


From your description, it sounds like the text is unconcealed when your cursor enters the line. The recommended option to avoid this is:

set concealcursor=nc

This will keep characters concealed until you actually want to operate on the hidden characters in visual or insert mode. You can read more with :h 'concealcursor'

Side note

Since you linked to them, I'll explain what those PRs actually fixed. (I'm their author)

Before it was fixed, Vim would conceal characters, but line lengths weren't updated and mouse clicks acted as if characters were still visible. It made tag navigation in help docs almost impossible to use with a mouse, which I felt would make it difficult for new users to actually learn Vim. Outside of the help docs, the problem got worse when Unicode characters were involved, especially double width characters.

For example, if you used a mouse to click on the first Y in your example (column 3 from your perspective), the cursor would actually jump to column 9. This is because that Y is actually on column 9. From your perspective, the cursor will appear to be on the second .

So, those PRs address an issue you would have in Vim if you enabled concealcursor normal mode.

  • I see. cocu=nc still feels suboptimal since then movement and normal mode operations on the line are really weird (i.e. l not visibly moving the cursor when over a concealed character, not seeing words etc.). This also does not fix the issue when clicking in insert mode :/ – 0x539 Jan 3 at 22:49
  • @0x539 The issue with motions boiled down to scripting consistency. I looked into addressing motions through key maps, but it was too slow to be worthwhile. For all the concealed chars I encounter, word motions or f/t were good enough. A Lua plugin might be faster than vimscript, though. That being said, your question was about mouse clicking ;) – Tommy A Jan 4 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.