Skip to content

Commit

Permalink
Add the first version of the code.
Browse files Browse the repository at this point in the history
Documentation is still based on range-search.vim and the convenient
normal mode keystrokes do not work, but we're getting there.
  • Loading branch information
shlomif committed Feb 27, 2012
0 parents commit 1329a24
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Rakefile copied from https://github.com/mileszs/ack.vim (license is
# unknown).
# Modified by Shlomi Fish, while disclaiming all rights to the modifications.
#
# Added by Josh Nichols, a.k.a. technicalpickles
require 'rake'

plugin_name = 'add-to-word-search'
files = ['doc/#{plugin_name}.txt', 'plugin/#{plugin_name}.vim']

desc 'Install plugin and documentation'
task :install do
vimfiles = if ENV['VIMFILES']
ENV['VIMFILES']
elsif RUBY_PLATFORM =~ /(win|w)32$/
File.expand_path("~/vimfiles")
else
File.expand_path("~/.vim")
end
files.each do |file|
target_file = File.join(vimfiles, file)
FileUtils.mkdir_p File.dirname(target_file)
FileUtils.cp file, target_file

puts " Copied #{file} to #{target_file}"
end

end
15 changes: 15 additions & 0 deletions doc/add-to-word-search.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*range-search.txt* Plugin for searching inside ranges

==============================================================================
Author: Shlomi Fish < http://www.shlomifish.org/ >
License: MIT/X11 ( http://www.opensource.org/licenses/mit-license.php )

==============================================================================

:[range]Rs {pattern} *:Rs*

Searches the range for the pattern.

:[range]RS {pattern} *:RS*

Same as :Rs.
42 changes: 42 additions & 0 deletions plugin/add-to-word-search.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
" Author: Shlomi Fish
" Homepage: http://www.shlomifish.org/
" Email: shlomif@cpan.org
" Date: 27 February 2012
" License: MIT X11 ( http://www.opensource.org/licenses/mit-license.php )
" Version: 0.2.0
"
" Motivation for this plugin:
" ---------------------------
"
" When searching through code I often found that I need to add more related
" terms to the search. For example, if I found a call to a function inside
" a different one, or when a type is typedef'ed to something else (in C).
" This module aims to allow you to convenietly add search terms to the search
" so you can find all the occurences of all of them.
" To use: put this in ~/.vim/plugin/
"
" Then you can type <Leader>** to add a search term to the search (mnemonic -
" * is the namespace and '*' searches forward for a keyword.

function! Append_pat_to_search(mypat)
let @/ = @/ . a:mypat
endfunction

" This recipe is based on:
"
" http://stackoverflow.com/questions/7093397/vim-equivalent-of-preg-quote-and-quotemeta
function! Quotemeta(mypat)
return '\V' . substitute(a:mypat,'\\','\\\\','g') . '\m'
endfunction

function! Append_keyword_to_search(mypat)
call Append_pat_to_search('\<' . Quotemeta(mypat) . '\>')
endfunction

" command -range -nargs=1 Rs call Range_Search(<f-args>,<line1>,<line2>)
" command -range -nargs=1 RS call Range_Search(<f-args>,<line1>,<line2>)

" Changelog:
"
" 0.2.0:
" first release.

0 comments on commit 1329a24

Please sign in to comment.