From 3db3c99696f7278db4d51b60e5d400a70c5e28b9 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Wed, 11 Sep 2013 00:00:00 +0200 Subject: [PATCH] file creation --- autoload/ingo/search/pattern.vim | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 autoload/ingo/search/pattern.vim diff --git a/autoload/ingo/search/pattern.vim b/autoload/ingo/search/pattern.vim new file mode 100644 index 0000000..5a6ab67 --- /dev/null +++ b/autoload/ingo/search/pattern.vim @@ -0,0 +1,32 @@ +" ingo/search/pattern.vim: Functions for the search pattern. +" +" DEPENDENCIES: +" +" Copyright: (C) 2011-2013 Ingo Karkat +" The VIM LICENSE applies to this script; see ':help copyright'. +" +" Maintainer: Ingo Karkat +" +" REVISION DATE REMARKS +" 1.006.001 24-May-2013 file creation + +function! ingo#search#pattern#GetLastForwardSearch( ... ) +"****************************************************************************** +"* PURPOSE: +" Get @/, or the a:count'th last search pattern, but also handle the case +" where the pattern was set from a backward search, and doesn't have "/" +" characters properly escaped. +"* ASSUMPTIONS / PRECONDITIONS: +" None. +"* EFFECTS / POSTCONDITIONS: +" None. +"* INPUTS: +" None. +"* RETURN VALUES: +" Last search pattern ready to use in a :s/{pat}/ command, with forward +" slashes properly escaped. +"****************************************************************************** + return substitute((a:0 ? histget('search', -1 * a:1) : @/), '\%(\%(^\|[^\\]\)\%(\\\\\)*\\\)\@