I use very few line breaks in my code, and for me keeping this vertical rhythm helps me:
Because of this, the line breaks I do use have a purpose. When writing HTML I keep modules or blocks of tags together, and I'll insert a single line break between sections to visually delineate where these blocks are.
<!DOCTYPE html>
<meta charset=utf-8>
<title>Example HTML Page</title>
<h1>Example Headline</h1>
<h2>Example Subhead</h2>
<p>Text</p>
<p>text</p>
<p>text</p>
<footer>© 2016 Company Name</footer>
When writing CSS I don't add extra line breaks between properties, or rules, though I do put a line break around @media queries, just to help see where they start. In CSS is where adding extra line breaks severely slows down reading time, and another thing - every rule begins at the left edge of the current indentation block (styles in queries are indented once). I've worked with CSS where child elements are indented underneath parent elements (not in SASS, in actual CSS) and that's the worst for being able to re-read and spot errors. Here's what a bit of CSS might look like formatted nicely:
* {
box-sizing: border-box;
}
body {
margin: 0;
}
html {
font-size: 12pt;
font-family: sans-serif;
}
@media (min-width: 500px){
body {
background: lime;
}
}
@media (min-width: 900px){
body {
background: red;
}
}
And lastly, in JavaScript I will often put an extra line break between variable declarations and the commands that follow, and may separate blocks of code or functions to group similar things together. Here's an example of JavaScript with line breaks where I feel they are most necessary:
var tag = document.querySelector('[data-plugin]')
for (i in tag){
tag[i].setAttribute('data-plugin',i)
}
function example(){
alert(tag.length)
}
document.addEventListener('click',example)
I hope that helps demonstrate how conservative use of line breaks can boost legibility and help make code more readable. Adding too many extra line breaks is often worse than including not enough line breaks for being able to read and digest code, so if anything I would lean on the side of using fewer line breaks once you're familiar with the language you're writing.
When you're learning, take as much space as you need to get the job done, and format you code nicely later (if it matters to you).