Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent VS Code from collapsing a trailing empty line?

I have a habit of using code editors for notes in the following fashion:

a topic
. a note
 ? a question regarding the note
  - a to do item
 . some more details
. another note
 . more details

another topic
...

What I like about VS Code is that it allows to fold (collapse) blocks in txt files based on their indentation (like for Python):

  a topic
+ . a note
  . another note
   . more details

  another topic
  ...

What I don't like, though, is that it also includes empty lines into collapsed blocks: the line after . more details has no indentation, but when I collapse that block I get

  a topic
+ . a note
+ . another note
  another topic
  ...

while I want it to be

  a topic
+ . a note
+ . another note

  another topic
  ...

Can you suggest what options should I change to get this difference about collapsing?

like image 383
YakovL Avatar asked Jan 23 '19 17:01

YakovL


People also ask

How do you break a long line in VS code?

On Windows, press Alt + Z (macOS: Option ⌥ + Z ) to toggle word wrapping, or, select View > Toggle Word Wrap from VSCode Menu. Show activity on this post. For Windows, Pressing Alt+Z will break the line.

How do you collapse a line of code or code of line?

Ctrl + Shift + [ on Windows and Linux. ⌥ + ⌘ + [ on macOS.


1 Answers

I don't know of a way to prevent the last line from being folded in VS Code, unless you use a 3rd party extension.

If you search extensions for 'folding' you should see several. Explicit Folding appears to have options to control this. But there are a lot more. Take a look & see if one fits your needs. If not then the only way to get this would be to develop an extension to handle this the way you want.

like image 155
nbppp2 Avatar answered Sep 28 '22 09:09

nbppp2