Thursday, December 17, 2009

vimscript: how to break from function if user input is ESC

Alrighty, basically I wrote a function to map to a key that does a recursive vimgrep. It looks like:

function! EasyVimGrep()
  let curline = getline('.')
  call inputsave()
  let q = input('vimgrep dis: ')
  call inputrestore()
  :execute "vimgrep /" . q . "/ **/*"
endfunction

But sometimes I change my mind when i call it, and I hit ESC to exit the input dialog. 

However hitting ESC still seems to execute the vimgrep.  Ctrl-C however, works to cancel it.

How do i do something like,  (if q == ESCAPE) return;  ?

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: