From 5b150bda13beae9175c56c47bfecd5ee5c7e2a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98ystein=20Walle?= Date: Thu, 10 Sep 2015 00:32:00 +0200 Subject: [PATCH] Handle that the comment marker can contain regex In the case of e.g. C Double-tap will correctly detect * as a potential character a comment can start with. But * has special meaning in regular expressions and in the case of Vim will trigger an error if not used correctly. Protect what Double-tap find by surrounding it in \V...\m. Thanks to @utrack for the idea. Fixes #5. --- plugin/double-tap.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/double-tap.vim b/plugin/double-tap.vim index 3594b61..1b76f2b 100644 --- a/plugin/double-tap.vim +++ b/plugin/double-tap.vim @@ -53,7 +53,7 @@ function! s:Detect_empty_comment() let s:commStart[&ft] = matchstr(&comments, s:pattern) endif let line = getline('.') - if s:commStart[&ft] != '' && line =~ '^\s*'. s:commStart[&ft] . '\s*$' + if s:commStart[&ft] != '' && line =~ '^\s*\V'. s:commStart[&ft] . '\m\s*$' return "\" else return "\"