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

  • Home
  • SEARCH
  • 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 6223065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:25:26+00:00 2026-05-24T08:25:26+00:00

I like to write code using the ternary ?: operator like this: std::string result

  • 0

I like to write code using the ternary ?: operator like this:

std::string result = input.empty() ? createNewItem()
                                   : processInput( input );

How can I configure vim so that when pressing Return after having typed createNewItem() indents the next line so that the cursor is in the same column as the last ? so that I can just continue typing : processInput( input );?

I tried looking at the cinoptions-values setting but I didn’t see anything relevant.

  • 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-24T08:25:27+00:00Added an answer on May 24, 2026 at 8:25 am

    Inspired by a roughly similiar question I exercised my vimscript-fu and created a little script to do this job:

    if (!exists("*CppIndentDepth"))
        function CppIndentDepth()
            let lineno = v:lnum
            let lastQuestionMark = match(getline(lineno-1), "?[^?]*")
            if lastQuestionMark != -1
                return lastQuestionMark
            endif
            return cindent(lineno)
        endfunction
    endif
    
    set indentexpr=CppIndentDepth()
    

    I saved this file as vimfiles/indent/after/cpp.vim and added filetype indent on to my .vimrc to toggle loading of indentation plugins. It seems to work good enough!

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

Sidebar

Related Questions

If I'm using a Hashtable , I can write code like this: object item
Using the C# compilers query comprehension features, you can write code like: var names
When I write code like this in VS 2008: .h struct Patterns { string
Before 2.1 I was able to write code like this (using the AddWhere): Query
Many beginning programmers write code like this: sub copy_file ($$) { my $from =
When I write code in Python with exception handling I can write code like:
i can write methods like that public void CompareEmail() { some code } public
Is it possible to write code like this? public void DoSomeOperation().Log() { }.Log() Above
Is it possible to write code like the following. I'm trying to using Moq
I would like to write a code in Ruby that behaves like this C#

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.