I am trying to write a small script to mimic the Notepad++ 's 'Find in Files'
feature.
First it collects information from the user e.g. search item, directory and
file-type,
then it should start performing.
I got stumbled somewhere, after searching the Internet a lot
I did not find any solution that worked in my case.
Here is the detail:
" ------------Find_in_Files.vim------------
" -----------------------Implementation of a simple feature
" -----------------------"Find in Files and Directories"
" -----------------------like Notepad++ -----------------
:menu Edit.Find\ in\ Files  :<Esc>:<Esc>:call Find_in_Files() <Cr>
function Find_in_Files()
" -----------------------raw method-----------------
" :vimgrep /GNU/ C:\CodeBlocks\TDM-GCC-64\include\*.txt
" :cw
" --------------------------------------------------
	let what2find = inputdialog("search term", "", "cancel pressed")
	let	directory	= browsedir("Browse the directory","")
	let filetype = inputdialog("filetype", "", "cancel pressed")
    if what2find != "" && what2find != "cancel pressed" && directory !=  ""
&& filetype !=  ""
        " :exe "!vimgrep /".what2find "\b/" " " .directory "\b\*." .filetype                
" not working
        :execute "vimgrep /".what2find "\b/" " " .directory "\b\*."
.filetype
        :cw
                  " also not working
    else
        "process if user press okay
        if what2find != "cancel pressed" && directory !=  "cancel pressed"
&& filetype !=  "cancel pressed"
               " I will repeat the same here if something goes well
        endif
    endif
endfunction
This plug-in is working partially, all the problem comes when I pass a
variable value from the user input to vimgrep.
If there is any fix to this problem please let me know.
--
View this message in context: http://vim.1045645.n5.nabble.com/How-can-I-pass-user-input-value-to-vimgrep-tp5721661.html
Sent from the Vim - General mailing list archive at Nabble.com.
-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, May 21, 2014
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment