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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:20:14+00:00 2026-06-10T01:20:14+00:00

I wish to map <D-1> to <- when i’m editing R files. I initially

  • 0

I wish to map <D-1> to <- when i’m editing R files.

I initially edited ~/.vim/bundle/Vim-R-plugin/ftdetect/r.vim and added:

inoremap <D-1> <space><-<space>

However it was available when i was editing all types of files — i tested .py and my .vimrc.

Why does this occur?

To fix the problem, i added:

autocmd FileType r inoremap <D-1> <space><-<space>

to my .vimrc. Now the map is not there when i initially open mvim, however once i’ve opened an *.r file, the mapping exists for all my other files.

To test what was going on, i added:

autocmd FileType python inoremap <D-1> <space>==<space>

and found that when i had loaded neither type of file, <D-1> wasn’t mapped; that when i loaded an *.r file, that <D-1> gave me <- (as desired) in *.r files, as well as in all other files — and when i next opened an *.py file, that <D-1> yielded == in all files — including in the *.r files.

Experimenting, i found that whatever file type i had most recently opened would define the mapping. This is undesirable behaviour when editing more than one filetype.

What is the best practice solution to this problem?

I use MacVim and manage my bundles with vundle.

  • 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-10T01:20:16+00:00Added an answer on June 10, 2026 at 1:20 am

    As sylvain.joyeux mentioned in his answer you should use ‘ftplugin’ directory for your mappings. But this won’t solve mapping issues. The reason why <D-1> mapping is available for all buffers is that you define it for all buffers (globally). If you want to limit a mapping to some particular buffer you should use <buffer> special argument of :map commands. So your mapping command should look like this:

    inoremap <buffer> <D-1> <space><-<space>
    

    See :help :map-<buffer> for details.

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

Sidebar

Related Questions

I wish to edit ini files over web server, decided to use django, been
I have the following map. I wish to map BasketItem to the class Product.
Fairly straightforward question. I have a map that I wish to initialize by calling
I have list of dictonaries. I wish type iterate over this list and map
What I wish to do is have a class that contains a map of
I have a Google Map created with V3 API, and I wish to apply
i have several markers on the google map displayed in android, i wish to
I have a list of items that I wish to map onto a ListView,
I wish to create a Map keyed by name containing the count of things
Wish to specify the the color of a map pin other than the default

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.