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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:21:08+00:00 2026-05-19T14:21:08+00:00

I know that to search for a whole word in vim you need to

  • 0

I know that to search for a whole word in vim you need to type:

/\<word\><CR>

Now, what I would like to do is to map this behaviour to ? (as I never search backwards, and if needed I could search forward and then NN). I.e. I’d like to type:

?word<CR>

and have the same result as above (vim searches the whole word). I’ve been fiddling around with vim commands and mappings for some weeks now, but I’m not sure about how to accomplish this one. Thank you for any help.

Update: (insead of ? I use \ now).

  • 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-19T14:21:08+00:00Added an answer on May 19, 2026 at 2:21 pm

    I tend to use * and # (as suggested by Brian Agnew), but if you want a method that involves typing

    ?word<CR>
    

    you could do something like this:

    function! SearchWord(word)
        let @/ = '\<' . a:word . '\>'
        normal n
    endfunction
    command! -nargs=1 SearchWord call SearchWord(<f-args>)
    nmap ? :SearchWord 
    

    Note there is a space after SearchWord on the last line.

    Explanation:

    The mapping will make ? open up a command prompt and type SearchWord (including the space). The command makes SearchWord myword do the equivalent of call SearchWord('myword') (i.e. it puts the quotes round the argument in order to make it into a string). The function sets the search register @/ equal to your word surrounded by \< and \> and then does a normal-mode n to find the next instance of the contents of the search register.

    Of course you lose the benefits of incremental searching if you do this, but hopefully it’s useful anyway.

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

Sidebar

Related Questions

https://search.twitter.com/search.json?q=doug How do I read this like VIEW SOURCE, so that I know what
I want to develop google desktop search like application, I want to know that
I don't know what name this goes by and that's been complicating my search.
I need to sort and search through a dictionary. I know that dictionary cannot
Perhaps, you know that google image search by local image file .. But, Google
i work in lamp environment . i search script that know to take a
1-)For sorted array I have used Binary Search. We know that the worst case
Anyone know what the best way is to search on a Field that hold
I know that this sort of question has been asked here before, but still
I need to know about the uniform cost search algorithm. In the uniform cost

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.