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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:45:29+00:00 2026-05-23T13:45:29+00:00

In Intellij Idea, there’s a feature. Let’s say I have used a variable myCamelCase

  • 0

In Intellij Idea, there’s a feature. Let’s say I have used a variable myCamelCase somewhere in my code. Then if I type mCC and press Ctrl–Enter or some such key combination, it expands to myCamelCase. Is there something similar in Vim?

  • 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-23T13:45:29+00:00Added an answer on May 23, 2026 at 1:45 pm

    Okay, forgive me for answering twice, but since my first attempt missed the point, I’ll have another go. This is more complicated than I thought, but possibly not as complicated as I have made it (!).

    This is now modified to suggest all matching variable names.

    First of all, here’s a function to generate the ‘mCC’ abbreviation from the ‘myCamelCase’ string:

    function! Camel_Initials(camel)
        let first_char = matchstr(a:camel,"^.")
        let other_char = substitute(a:camel,"\\U","","g")
        return first_char . other_char
    endfunction
    

    Now, here’s a function that takes an abbreviation (‘mCC’) and scans the current buffer (backwards from the current line) for “words” that have this abbreviation. A list of all matches is returned:

    function! Expand_Camel_Initials(abbrev)
        let winview=winsaveview()
        let candidate=a:abbrev
        let matches=[]
        try
            let resline = line(".")
            while resline >= 1
                let sstr = '\<' . matchstr(a:abbrev,"^.") . '[a-zA-Z]*\>'
                keepjumps let resline=search(sstr,"bW")
                let candidate=expand("<cword>")
                if candidate != a:abbrev && Camel_Initials(candidate) == a:abbrev
                    call add( matches, candidate )
                endif
            endwhile
        finally
            call winrestview(winview)
            if len(matches) == 0
                echo "No expansion found"
            endif
            return sort(candidate)
        endtry
    endfunction
    

    Next, here’s a custom-completion function that reads the word under the cursor and suggests the matches returned by the above functions:

    function! Camel_Complete( findstart, base )
        if a:findstart
            let line = getline('.')
            let start = col('.') - 1
            while start > 0 && line[start - 1] =~ '[A-Za-z_]'
                let start -= 1
            endwhile
            return start
        else
            return Expand_Camel_Initials( a:base )
        endif
    endfunction
    

    To make use of this, you must define the “completefunc”:

    setlocal completefunc=Camel_Complete
    

    To use insert-mode completion, type CTRL-X CTRL-U, but I usually map this to CTRL-L:

    inoremap <c-l> <c-x><c-u>
    

    With this code in your vimrc you should find that typing mCC followed by CTRL-L will make the expected replacement. If no matching expansion is found, the abbreviation is unchanged.

    The code isn’t water-tight, but it works in all the simple cases I tested. Hope it helps. Let me know if anything needs elucidating.

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

Sidebar

Related Questions

There's a small feature I have been yearning about in intellij idea and I
I've used various IDE's (Eclipse, NetBeans, Intellij IDEA) and although all of them have
I have used IntelliJ Idea on a few projects and I really like the
When in incremental search mode in Intellij IDEA, is there a way to select
The IntelliJ IDEA short-cut to reformat source code is Ctrl + Alt + L
I have a problem with my IntelliJ idea 9 IDE. I installed the La
I have a Java EE 6 Wicket application deployed with maven using IntelliJ IDEA
Is there path macros in IntelliJ IDEA that points to project directory ? In
IntelliJ IDEA features the ability to perform spell checking of source code, and this
I have an IntelliJ IDEA project contains two Scala modules M1 and M2. Each

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.