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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:05:57+00:00 2026-05-19T15:05:57+00:00

I came to an idea that <C-a> in Vim’s normal mode should not only

  • 0

I came to an idea that <C-a> in Vim’s normal mode should not only increase numbers but toggle booleans. It makes sense if you consider true and false as integers modulo 2.

So, I downloaded an excellent script to do the hairy work and wrote a new definition for <C-a>:

fun! NewCA()
    let cw = tolower(expand("<cword>"))
    if cw == "true" || cw == "false"
        ToggleWord
    else
        " run the built-in <C-a>
        execute "normal \<C-a>"
    endif
endfun
command! NewCA :call NewCA()
nnoremap <C-a> :NewCA<cr>

But as it happens, nnoremap doesn’t go as far as to check inside functions. I get recursive behaviour if my cursor is not on words true or false.

In this point I swear a lot, why didn’t Bram go pick an excellent idea from Emacs, that everything should be functions and key bindings freely setable. Then I just could check the function for <C-a> and call it in that function. But no, I can’t find such a function, and the execute "normal foo" phrases seem to be the Vim idiom.

Any suggestions on how I could make <C-a> work such that

  • Toggle booleans when the cursor is over a word true or false
  • Fall back to built-in <C-a> behaviour otherwise

Help appreciated!

  • 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-19T15:05:58+00:00Added an answer on May 19, 2026 at 3:05 pm

    change

    execute "normal \<C-a>"

    to:

    normal! ^A

    you can get ^A by running

    <C-v><C-a>

    in normal mode

    the “!” at the end of normal say “use default mapping”

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

Sidebar

Related Questions

I generally prefer constness, but recently came across a conundrum with const iterators that
I recently came upon the scary idea that Integer.count loops in Ruby start from
Few days ago I've a weird idea came into my mind that manipulate if();
I came across an interesting package that does fast navigation by character, but I
I need your help on an idea that came to my mind recently. Speaking
In our team we came up with the idea that we have to do
I came up with the idea that if we remove the exponential backoff time
I was just having a nap and then that crazy idea came into my
I just came across an idea in The Structure And Interpretation of Computer Programs
Came by a curious case today, that got me thinking about how the object

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.