summaryrefslogtreecommitdiffstats
path: root/runtime/doc/tips.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2006-02-18 22:14:51 +0000
committerBram Moolenaar <Bram@vim.org>2006-02-18 22:14:51 +0000
commit7e8fd63682801d6cdd7f31972540c21f148b289e (patch)
treecbc44d7f10ef0a87454582fbff40fe930bacc6b6 /runtime/doc/tips.txt
parent997fb4ba696625e27e17c00d5033b20411aa45a3 (diff)
updated for version 7.0201v7.0201
Diffstat (limited to 'runtime/doc/tips.txt')
-rw-r--r--runtime/doc/tips.txt11
1 files changed, 8 insertions, 3 deletions
diff --git a/runtime/doc/tips.txt b/runtime/doc/tips.txt
index 2fc1bee0c7..30c548d61d 100644
--- a/runtime/doc/tips.txt
+++ b/runtime/doc/tips.txt
@@ -1,4 +1,4 @@
-*tips.txt* For Vim version 7.0aa. Last change: 2006 Feb 16
+*tips.txt* For Vim version 7.0aa. Last change: 2006 Feb 18
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -450,11 +450,13 @@ Highlighting matching parens *match-parens*
This example shows the use of a few advanced tricks:
- using the |CursorMoved| autocommand event
- using |searchpairpos()| to find a matching paren
+- using |synID()| to detect whether the cursor is in a string or comment
- using |:match| to highlight something
- using a |pattern| to match a specific position in the file.
This should be put in a Vim script file, since it uses script-local variables.
-Note that it doesn't recognize strings or comments in the text.
+It skips matches in strings or comments, unless the cursor started in string
+or comment. This requires syntax highlighting.
>
let s:paren_hl_on = 0
function s:Highlight_Matching_Paren()
@@ -484,8 +486,11 @@ Note that it doesn't recognize strings or comments in the text.
let c = '\['
let c2 = '\]'
endif
+ let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
+ \ '=~? "string\\|comment"'
+ execute 'if' s_skip '| let s_skip = 0 | endif'
- let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags)
+ let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip)
if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$')
exe 'match Search /\(\%' . c_lnum . 'l\%' . c_col .