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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:58:06+00:00 2026-06-12T12:58:06+00:00

I’m trying to get vim to indent continuation lines starting on a new line

  • 0

I’m trying to get vim to indent continuation lines starting on a new line this way:

def foo
  open_paren_at_EOL(
      100, 200)

  a = {
      :foo => 1,
  }
end

Vim 7.3’s default indentation [1] for those lines looks like this:

def foo
  open_paren_at_EOL(
    100, 200)

  a = {
    :foo => 1,
  }
end

I have tried multiple cino= values and I even tried adapting the .vim script from [2] but with no success.

My .vimrc is here:

https://github.com/slnc/dotfiles/blob/master/.vimrc

Thanks!

  • [1] https://github.com/vim-ruby/vim-ruby/blob/master/indent/ruby.vim
  • [2] "Google" python style script not working
  • 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-12T12:58:07+00:00Added an answer on June 12, 2026 at 12:58 pm

    What you could do to get this kind of indenting is to find out which areas of the GetRubyIndent function are relevant to these continuations and increase the return values. For the example you gave, this seems to do the job:

    diff --git a/indent/ruby.vim b/indent/ruby.vim
    index 05c1e85..6f51cf2 100644
    --- a/indent/ruby.vim
    +++ b/indent/ruby.vim
    @@ -368,7 +368,7 @@ function GetRubyIndent(...)
    
      " If the previous line ended with a block opening, add a level of indent.
      if s:Match(lnum, s:block_regex)
    -    return indent(s:GetMSL(lnum)) + &sw
    +    return indent(s:GetMSL(lnum)) + &sw * 2
      endif
    
      " If the previous line ended with the "*" of a splat, add a level of indent
    @@ -383,7 +383,7 @@ function GetRubyIndent(...)
        if open.pos != -1
          if open.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
            if col('.') + 1 == col('$')
    -          return ind + &sw
    +          return ind + &sw * 2
            else
              return virtcol('.')
            endif
    

    I’m not entirely sure if this won’t break anything else, but it seems like a safe change to me. If you find cases that don’t indent the way you want, you could just fix it the hard way: search for return within the limits of the function, then increase the indentation that is returned by one more &shiftwidth (or &sw). Check if it works, and if it doesn’t, undo and then move on to the next return, until you actually find it.

    You could fork vim-ruby, or you could just copy the indent/ruby.vim file to ~/.vim/indent/ruby.vim and change it as you wish. It should have priority over the bundled indent/ruby.vim.

    If you’re looking for a completely unobtrusive solution, that would be difficult. Theoretically, you could
    override the GetRubyIndent function as an indenter by using setlocal indentexpr=CustomGetRubyIndent(v:lnum), and then define a CustomGetRubyIndent function, which implements your behaviour in particular cases only and delegates to GetRubyIndent. I wouldn’t recommend going that far, though, it could get rather messy.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.