It’s a 2,000 line behemoth. It’s hard to browse or easily find what you are looking for in there. What can be done? This article isn’t about actually dismantling the file (although that would be a good one), it’s mostly about what to do when you need to leave the file that way.
Don’t Make Files That Big
Ideally, you don’t let files get too long. The longer the file the more likely it is that it’s become a dumping ground rather than a proper cog in the machine.
We’re talking about authored files here. Your production `style.css` file probably is quite long, but it’s probably compiled from smaller bits, organized into sensical parts.
If your authored files are already too long, can you find a way to break it apart that makes sense? If you can, it’s probably a good idea. Perhaps your monster `user_controller.rb` can be split up into concerns which the main controller can inherit.
Abstraction at work!
But let’s say, for whatever reason, it makes sense to have a mega-long file in your project. It needs to be that way, and you need a way to make it more manageable. Maybe we can have a little fun with it.
ASCII Art Blocks
If you do a lot of scrolling up and down the file, perhaps putting a bunch of space between sections is helpful. And then how about a big commented block of ASCII art text to label the section?
______
| ____|
| |__ ___ _ __ _ __ ___ ___
| __/ _ \| '__| '_ ` _ \/ __|
| | | (_) | | | | | | | \__ \
|_| \___/|_| |_| |_| |_|___/
If you use an editor with a “mini map”, these can really stand out, as pointed out by Xah Lee:

Comment Blocks
Maybe it’s just the space and the big block of commented code that stands out, so instead of being fancy artistic, maybe get real practical and label each section with metadata.
/*
Section: Form Styles
Purpose: To style form elements like <input>s and <button>s and such.
Author: Chris Coyier
Last updated: September 28, 2015
Favorite TV Show: Northern Exposure
*/
Weird Indentation
Code tends to cluster to the left. It looks weird when things are indented pretty far without nesting that leads to it. Perhaps you can use that do your advantage.
.main-header {
background: black;
color: white;
}
// *****************
// -----------------
// FOOTER STYLES
// _________________
// *****************
.main-footer {
background: white;
color: black;
}
Long Lines
Especially if you don’t have wrapping/soft-wrapping turned on, super long lines can be a nice way to break things up.
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Things You Can Search For
If you used a convention for how you named sections, that makes searching through the project (or parts of the project, or single files) yield good results for finding those sections.

Searching is so much faster than scrolling!
Use Code Folding Feature
If your editor features code folding, make use of it! The whole point of it is to temporarily visually hide blocks of code so they aren’t distracting.

Sourcemaps
If you write in a language that compiles to something else that the browser uses (e.g. Sass, CoffeeScript, Closure compiler, etc) it may offer source maps, meaning the DevTools can tell you what line a bit of code is on in the original authored file, not just the compiled version. That way you know exactly file you need to go to to edit it:

And you know what line as well, so you can jump right to it no matter where it is.
Does your editor help you in special ways?
Is your editor really good with it’s “Find in Project” feature that jumps you right to the line? Use it!
Does your editor have some cool way to jump around in files? I know “Go To Symbol” is pretty popular in Sublime Text and Jetbrains has it (I’m sure many others as well).
Does your editor (or an add-on) have some way to tab through sections of code? Try it!
ASCII Art Blocks is useful especially with sublime text mini map
I still use Coda so I tend to rely on their ! comment banners so that the section title appears as it’s own item in the code navigator among the functions, methods, class definitions, include/require calls, etc.
Or don’t have large files in the first place, which is advisable for a variety of reasons. Use Sass/PostCSS/anything for CSS; browserify for Javascript; any SSI for HTML. Having 2000-lines files is just poor management and comment blocks don’t save you from anything.
I didn’t read the article before commenting, shame on me. :(
Cool – the first time those mini maps seem to make sense to me (kindof).
The font has to be some “filled” variant, though – the one in the screenshot seems to be “Banner3” (from the linked generator).
Of course, keeping those file sizes in check would be preferable, as mentioned. And then – adding 7 character tall comments to each section doesn’t help the vertical file size exactly ;) So I certainly prefer good structure and searching. But for inherited chaos that isn’t worth cleaning up – maybe. So thanks for the tip!
There is a package “minimap” for atom, as well, BTW.
But, really, don’t write files that large!
Chances are that you’re packing very different kinds of functional code, so it’s only natural to separate them in different files.
Nice tricks with the minimaps, anyway.
I use sublime text 3 and opening/closing a comment like:
will add a solid bright pink background colour (You can’t miss it) to all text inside. Embarrassingly, I don’t remember ever setting anything like that up in Sublime settings, but I think it has something to do with the theme “Monokai”.
https://packagecontrol.io/packages/Theme%20-%20Monokai
Oh dear! I also don’t ever remember adding that image as my Gravatar! Sorry!
I use visual studio with Web essentials, it collapses trees of code, but i still go for breaking it up into multiple files
Forgot to mention, this is for Lesscss
Visual Studio with Web Essentials and for CSS I use comment Regions and then ctrl M+L collapses everything!
If you are using Githubs Atom editor there’s a plugin that does the ASCII Banner stuff exceptionally well: https://atom.io/packages/figlet
Write a word in your code, press the keybord-combo. Done!
In combination with the toggle comment function (Shift+Cmd+3 on a Mac) you don’t need much more time than typing the text.
You can even select from different ASCII-art font styles.
…oh and theres something very similar for Sublime Text (2 & 3):
https://github.com/adamchainz/SublimeFiglet
For Sublime Text, there is the Table of Comments package that creates a navigation for comments that start with a specific marker (
>
by default).In our team, for Sass/Less we standardized on using
#
(like Markdown titles), and we use some formatting to make them more obvious when browsing code:But the decorations are not that important, and you could use *doc-style comments (
/** # Hello there */
) instead.These days I’m using Atom so I’m missing that feature. I try to rely on breaking code in separated files, which we do, but some components still have 200 or even 500 lines of styles, so a little bit of structure would still help navigate and of course maintain them.
In addition to write a summary, I usually like to put a quick DOM overview in my CSS. That is often time saving.
Wow!
That “Comment Blocks” styles seems to be very practical for very large styles and larger teams.