Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to draw vertical lines between braces in vim?

Tags:

c

vim

How can we have a vertical line shown between the braces in vim editor. It is helpful when I am writing C code.

Upto now, while using vim editor, if i want to know the position of the closing brace, i do following:

  1. In normal mode, I take the cursor to opeining brace { and then press % which take the cursor to closing }.

  2. And then (try) to remember the line numbers of opening and closing brace.

But when I do this I often forget the line numbers of opening and closing braces. Plus, many times the brace pairs are nested which makes it more confusing to remember.

So I want to have a vertical line drawn between the braces, so that I can do the following:

  1. In normal mode, take the cursor to open { and press j or k (or even % or any other motion command) to navigate through the file. But with an added line on the left side so that i can know which block I am in.

So, if the code is indented properly, then by looking at the line on the left side I will always have a track of which block I am in. And can use j and k (or any other motion command) without having to remember the line number of opening and closing brace.

How can we do this in vim ?

Update: Got the answer here Is it possible to display Indentation guides in Vim? .

like image 466
sps Avatar asked Dec 25 '22 18:12

sps


1 Answers

The indentLine plugin can help you indentLine pluginshttps://github.com/Yggdroot/indentLine (new location)

like image 54
Ôrel Avatar answered Jan 17 '23 08:01

Ôrel