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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:50:45+00:00 2026-06-13T22:50:45+00:00

Good day, I have a simple function I have mapped to CTRL + L

  • 0

Good day,

I have a simple function I have mapped to CTRL+L which I use in normal-mode to search for all instances in a project of a word or variable:

" Find all occurences in files
map <C-l> :execute " grep -srnw --binary-files=without-match --exclude=*~ --exclude-dir=.svn  . -e " . expand("<cword>") . " " <bar> cwindow<CR>

I am trying to make a command-mode function out of this so I could do something like:

:mySearchFunction wordToFind

This way, I effectively get a short and simple “Find in All Files” function so I don’t have to type the lengthy grep function above all the time. I have tried modifying the code after the . -e " .expand... piece of the function, but I am not familiar with writing VI/VIM functions. I am familiar with C and BASH scripting, but I cannot get this function working as expected.

May I have some assistance with making a command-mode function from this mapping of mine?

Thank you.


Edit: Posting modified version of the answer from @Conner. Also excludes the CTAGS tags file.

command! -nargs=1 SearchAll execute " grep -srnw --binary-files=without-match --exclude={*~,tags} --exclude-dir=.svn  . -e " . expand("<args>") . " " <bar> cwindow
map <C-l> :SearchAll <cword><CR>
  • 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-13T22:50:45+00:00Added an answer on June 13, 2026 at 10:50 pm
    command! -nargs=1 MySearchFunction execute " grep -srnw --binary-files=without-match --exclude=*~ --exclude-dir=.svn  . -e " . expand("<args>") . " " <bar> cwindow
    map <C-l> :MySearchFunction <cword><CR>
    

    Might I suggest looking into ack and Ack.vim.

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

Sidebar

Related Questions

Good Day, I have a simple working routine in Perl that swaps two words:
Good day, If I have for example the documents which have the following fields
Good day all, I have a preset situation that can't be changed, that revolves
Good day, I have a simple question (I hope). How do I access the
Good day, I have a practical mysql question to which I can't find help
Good day once again. I have a (seemingly) simple problem. I'm trying to display
Good day, I have a fairly simple question to experienced C# programmers. Basically, I
Good day to all, Can some one guide me in displaying a simple post
Good Day all, i have been working with http://jsfiddle.net , the sample app i
Good day I have manage to create my small and simple application, work with

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.