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 3870962
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:46:41+00:00 2026-05-19T21:46:41+00:00

I use https://github.com/cakebaker/scss-syntax.vim for syntax highlighting SCSS (or SASS ) files on vim, which

  • 0

I use https://github.com/cakebaker/scss-syntax.vim for syntax highlighting SCSS (or SASS) files on vim, which works very well for syntax highlighting. However, the plugin does not come with an indent file and am having trouble writing one.

I would like to set the indent to look like this:

enter image description here

However, if i do gg=G, I get:

enter image description here

I suspect that it does not understand nested indent based on braces. I tried all the different combinations of

set cindent

set nocindent

set autoindent

set smartindent

and tried to use the code from Tab key == 4 spaces and auto-indent after curly braces in Vim , including

set tabstop=2

set shiftwidth=2

set expandtab

…but nested braces indent never seems to work.

I believe that I might want to write a custom indent file, and all I need is indentation based on braces with nested levels. How should I go about this? If someone has an indentation file for filetypes with similar syntax, that will be great as well.

  • 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-05-19T21:46:41+00:00Added an answer on May 19, 2026 at 9:46 pm

    This is a quick hack, based on the built-in perl indentation code (in indent/perl.vim). Hopefully you can use it to get what you want to do. See the more detailed comments in either the perl indentation code or another one of the files in the indent directory for more details.

    setlocal indentexpr=GetMyIndent()
    function! GetMyIndent()
        let cline = getline(v:lnum)
    
        " Find a non-blank line above the current line.
        let lnum = prevnonblank(v:lnum - 1)
        " Hit the start of the file, use zero indent.
        if lnum == 0
            return 0
        endif
        let line = getline(lnum)
        let ind = indent(lnum)
    
        " Indent blocks enclosed by {}, (), or []
        " Find a real opening brace
        let bracepos = match(line, '[(){}\[\]]', matchend(line, '^\s*[)}\]]'))
        while bracepos != -1
            let brace = strpart(line, bracepos, 1)
            if brace == '(' || brace == '{' || brace == '['
                let ind = ind + &sw
            else
                let ind = ind - &sw
            endif
            let bracepos = match(line, '[(){}\[\]]', bracepos + 1)
        endwhile
        let bracepos = matchend(cline, '^\s*[)}\]]')
        if bracepos != -1
            let ind = ind - &sw
        endif
    
        return ind
    endfunction
    

    Save that file as ~/.vim/indent/something.vim where something is your file type (replace ~/.vim with the path to vimfiles if you’re on Windows.

    You might also want to stick this at the start of the file (but only if there isn’t some other indent declaration that might be loaded first):

    " Only load this indent file when no other was loaded.
    if exists("b:did_indent")
        finish
    endif
    let b:did_indent = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Cufon ( https://github.com/sorccu/cufon/wiki/about ) to use special fonts in my website. But
The class I wish to use is: https://github.com/philsturgeon/codeigniter-curl/blob/master/libraries/Curl.php How can I use this in
bit of a silly question but how do I use the linkedin gem(https://github.com/pengwynn/linkedin) I
I want to use Redis. So I followed this tutorial: https://github.com/sebleier/django-redis-cache First, I install
I use Rails 3, Capybara 0.4.0, Akephalos (https://github.com/sorentwo/akephalos) Selenium-webdriver and Rspec 2. I use
Seems like both EnyimMemcached ( https://github.com/enyim/EnyimMemcached ) and BeITMemcached ( http://code.google.com/p/beitmemcached/ ) are popular
I'm looking for a solution similar to the iPhone Facebook Connect ( https://github.com/facebook/facebook-ios-sdk )
I use http://github.com/abraham/twitteroauth PHP library for reaching Twitter REST API: <?php session_start(); require(config.php); require(twitteroauth/twitteroauth.php);
I use http://github.com/abraham/twitteroauth PHP library for reaching the Twitter REST API. My config file
I'm trying to use MongoDB with my POCOs. Using mongodb-csharp library ( http://github.com/samus/mongodb-csharp ),

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.