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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:46:52+00:00 2026-05-17T16:46:52+00:00

I want to map Ctrl – M to Ctrl – N in insert mode.

  • 0

I want to map Ctrl–M to Ctrl–N in insert mode. If I simply do imap <C-M> <C-N> then Ctrl–M does start to behave just like Ctrl–N, but then hitting Enter does the same as well. I want pressing Return to keep inserting new lines, and at the same time make Ctrl–M insert the next keyword completion match just like Ctrl–N does. Is that possible?

EDIT:
I managed to modify Vim’s source code to unconditionally treat Ctrl–M as Ctrl–N without affecting Return. While doing so I also realized that indeed there is no way to do that without source code change, as the distinction between what has actually been pressed – Enter or Ctrl–M, appears to vanish much too early in key-press processing. It happens in platform-dependent UI modules, and the portable code part in key-press handling already has no idea if Ctrl–M or Return was actually pressed that resulted in key code 13.

My modifications were in GUI modules for FreeBSD (GTK) and Windows, as those are the platforms I use gvim on most often.

P.S. If anyone ever wants to achieve the same, please feel free to drop me a note.

P.P.S. To all who have provided answers to this question: thank you very much! Your comments helped me a lot.

  • 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-17T16:46:52+00:00Added an answer on May 17, 2026 at 4:46 pm

    If you are using Windows, you can probably use Autohotkey to re-map Ctrl-M while in insert mode if the active window is vim.

    The ahk script would probably look something like this:

     #IfWinActive, Write: ahk_class GVIM
     ^M::^N
    

    Alternately, you might consider working on your touch typing skills (I doubt you want to hear that solution, but I still think it’s a valid suggestion) to avoid getting Ctrl-M and Ctrl-N confused.

    If you are using some flavor of Linux, I am not sure what tools could be equivalent to autohotkey.

    Another alternative is to map a completely different key to let you do autocompletion, instead of using ctrl-n, such as Ctrl-K: :inoremap <c-k> <c-n>

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

Sidebar

Related Questions

I have a simple goal: Map Ctrl-C, a command I don't think I've ever
I want to map 127.0.0.1 to multiple names instead of the standard way as
I want to map my F2 for nerdtree with the following entry: map <F2>
I want to map pointer to integer for purpose of serialization. The pointers may
I have to tables I want to map to each other. I want to
I have a large table that I want to map to a few entities.
In my global asax file, I want to map a route such as this:
I need something of a HashMap in javascript. Can we do this: var map
I want to make a C# Dictionary in which the key is the string
I want to send unique references to the client so that they client can

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.