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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:58:49+00:00 2026-06-09T16:58:49+00:00

I know my title is not that descriptive/clear so let me explain. Yesterday I

  • 0

I know my title is not that descriptive/clear so let me explain.

Yesterday I can across Vimgrep and copen so I added the below line in .vimrc

nnoremap <silent> ,/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>

What it does is open a quickfix list for the searched(highlighted) word in vim.

Now when you press Enter<CR> in quickfix list it takes you to a corresponding line in the main Vim Window.

Now, the problem I am facing is I have mapped my <CR like map <CR> o<Esc> which creates a new line just below the current line.

So, as you can see there is a conflict b/w the two. So, what I am trying is to come up with a vim function like

Pseudo Code

function IfNotInsideQuickFix()
    if buffer != QuickFix
        then map <CR> o<Esc>
    elif buffer == QuickFix
         Normal behaviour

Call function

Here is the output of :buffers

:buffers
  1 #a   "test.cs"                      line 0
  2 %a-  "[Quickfix List]"              line 1
Press ENTER or type command to continue

I have no experience in writing vim functions. So, can someone please guide me to it.

PS: I know that I can change my Vim mapping to create a new line but I want to learn how to do it via Vim function

  • 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-09T16:58:50+00:00Added an answer on June 9, 2026 at 4:58 pm

    You can keep your global <CR> mapping as-is, but locally in quickfix windows restore the original behavior. This is done via an :autocmd (triggered when the quickfix window opens) that maps (without remapping) <CR> (locally via <buffer>) onto itself.

    :autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know my title is not descriptive so let me try to explain it
Sorry if the title is not that specific, but I don't know how else
I understand that the title might not be descriptive enough, but I'm making a
The title is pretty descriptive... Is there any extension that let me see FULL
First off, I'm not entirely sure that my question title is very descriptive, so
I know the title isn't the most descriptive, but I can't think of a
(using jQuery 1.4.4 edition) The title of the question might not be that clear,
Sorry if the title is not too descriptive, but I didn't know how to
I know the title of this question is not very descriptive, but I didn't
First off, I know the title is generic and not fitting. I just couldn't

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.