1

I find it really annoying that when I use standard hjkl or arrow key navigation in Vim, then Vim highlights the curly braces and gets stuck on them.

Here is an example of what I'm talking about:

here is some text
{

} {

} here is some text

Whether I'm in normal or insert mode, Vim gets stuck on any of the braces before moving on to the part that says "here is some text", and I have to press j/k or up/down several times before the cursor leaves the braces.

I'm well aware of the {} and [[]] keys as a way of navigating the braces, but I don't want that as much as I want to just have straightforward navigation through a text file.

Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37
  • 1
    Read :h showmatch. – 3N4N Dec 08 '22 at 06:41
  • Putting set noshowmatch in your .vimrc partially fixes it: when you get to the brace, then it skips to the bottom one and cycles up to the top one before going back to everything else. This takes the same amount of typing it would normally, even though i guess it would be nice if it just treated the curly braces like every else until you specify a curly brace search or something else... –  Dec 08 '22 at 07:10
  • 2
    you can also just remove the braces fro mthe matchpairs option – Christian Brabandt Dec 08 '22 at 07:23
  • @Christian Brabandt what does that entail? –  Dec 08 '22 at 08:05
  • Sorry, I don't understand the question. – Christian Brabandt Dec 08 '22 at 08:16
  • I don't think even with showmatch or matchpairs you should have to press k more than once to go from { to the line above. – D. Ben Knoble Dec 08 '22 at 17:27
  • @D. Ben Knoble Should and functionality are two different things, before i made the with set noshowmatch, my cursor would get stuck one brace and then i'd have to press k or j several times to get out of it. I think this is caused just because the navigation is no longer clearly visible when you have showmatch turned on. –  Dec 08 '22 at 17:37
  • @thinksinbinary try How to debug my vimrc. Even with a very configured vim, turning on showmatch and pasting your example, I didn't have this problem. – D. Ben Knoble Dec 08 '22 at 17:41
  • i don't add plugins to vim because it's already such an absurd program, it's been doing this just basic vim. Maybe the code i added to tell it to remember where the cursor was somehow effected it this way. Maybe "set numbers" did that. I don't know and i'm not trying to be a masochist about how i use vim. –  Dec 08 '22 at 20:04
  • @D. Ben Knoble You are correct though that it has something to do with something i added to the .vimrc file, because the problem is gone even though i just commented out everything. I guess i'll go through each of the lines and make the code work again one by one, then read the article. The things i have done are very simple though, the file is only 35 lines long. –  Dec 08 '22 at 23:32
  • The only thing i have found in my .vimrc file (assuming that nothing i added after making this post could have had anything to do with it, i've left those commented for now anyways) that has an effect on how the cursor moves through the braces is the the color scheme: set colorscheme darkblue, by putting a little underline on the line above, and having the cursor start in the opposite direction from my navigation. I wasn't able to reproduce the problem i originally had when i posted this with the cursor getting stuck and having to jam j or k to get out, so prolly a different bug. –  Dec 08 '22 at 23:50
  • 1
    Voting to close because the accepted answer is a workaround for a still-undiagnosed issue in the OP's configuration. – Rich Aug 17 '23 at 10:57

1 Answers1

1

To follow @Christian suggestion you can do:

:set matchpairs-={:}
Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37
  • Nice, that works perfectly. I'll remember that if i have issues with other metas –  Dec 08 '22 at 17:10
  • you can even use {}[[]] after making this change to navigate between the braces, someone editing a file with tons of functions may way to keep that the way it normally is since the cursor always starts at the bottom of a curly brace pair normally. –  Dec 08 '22 at 17:39