Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8391911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:22:54+00:00 2026-06-09T19:22:54+00:00

When I am viewing long code files with verbose comments in Vim, I would

  • 0

When I am viewing long code files with verbose comments in Vim, I would like to be able to load the files with comments folded but everything else unfolded. The current folding configuration I have in my .vimrc is:

set foldmethod=syntax
set nofoldenable

That way, when I want to start doing folds, I can just start executing z commands. But is there a way to only fold the (block) comments?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T19:22:56+00:00Added an answer on June 9, 2026 at 7:22 pm

    You could execute a global command to close all the block comment folds:

    :g/^\/\*/foldc
    

    This will execute :help foldclose on any line that starts with /* (a common block comment indicator). Notice the / and * need to be escaped in this instance. You don’t need to escape the / if you use a different delimiter (e.g. :g#^/\*#foldc). If you want this to happen automatically you could add it in an autocommand. For example:

    set fdm=syntax fen
    augroup closeCommentFolds
       au!
       au FileType javascript %foldo | g/^\/\*/foldc
       au FileType ruby %foldo | g/^=begin/foldc
    augroup end
    

    Note that in these examples the ^ character in regex specifies that the /* and =begin matches are at the beginning of the line. If you want to match if there’s whitespace between the beginning of the line and the match then use ^\s* instead of ^. The %foldo will open all folds so that foldenable is set, but it won’t fold everything (just comments in this case).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When viewing lots of webpages' source code (like JS,CSS,HTML), I find them in one
When viewing piped output to Less, sometimes I'd like to be able to view
I'm viewing variables using the debugger. In debug builds everything in the code below
While viewing jQuery's uncompressed source code I stumbled upon something I don't quite understand.
I'm currently designing a website that would involve storing a long list of names
On one of my pages I would like to display a subset of a
I've got a table with 6 columns: id name type_id code lat long The
I have PDF files I need to prepare for viewing on mobile devices. The
What would be the easiest way to extract the Lat and Long fields of
I've split the code window for a long css file into two sections, top

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.