Skip to content

Commit 0ab4b7e

Browse files
Yuheng Xievim-scripts
Yuheng Xie
authored andcommitted
Version 1.1.4: use map-<silent> to avoid echo on the command line
1 parent 30664f3 commit 0ab4b7e

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

plugin/mark.vim

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" Script Name: mark.vim
2-
" Version: 1.1.2
2+
" Version: 1.1.4
33
" Last Change: March 23, 2005
44
" Author: Yuheng Xie <[email protected]>
55
"
@@ -43,20 +43,41 @@ hi MarkWord6 ctermbg=Blue ctermfg=Black guibg=#9999FF guifg=Black
4343
" you may map keys to call Mark() in your vimrc file to trigger the functions.
4444
" examples:
4545
" mark or unmark the word under or before the cursor
46-
nmap \m :let w=PrevWord()<bar>if w!=""<bar>cal Mark("\\<".w."\\>")<bar>en<cr>
46+
nmap <silent> \m :let w=PrevWord()<bar>
47+
\if w!=""<bar>
48+
\cal Mark("\\<".w."\\>")<bar>
49+
\en<cr>
4750
" manually input a regular expression
48-
nmap \r :cal inputsave()<bar>let r=input("@")<bar>cal inputrestore()<bar>if r!=""<bar>cal Mark(r)<bar>en<cr>
51+
nmap <silent> \r :cal inputsave()<bar>
52+
\let r=input("@")<bar>
53+
\cal inputrestore()<bar>
54+
\if r!=""<bar>
55+
\cal Mark(r)<bar>
56+
\en<cr>
4957
" clear the mark under the cursor, or clear all marks
50-
nmap \n :cal Mark(ThisMark())<cr>
58+
nmap <silent> \n :cal Mark(ThisMark())<cr>
5159
" jump to the next occurrence of this mark
52-
nnoremap * :let w=ThisMark()<bar>if w!=""<bar>cal search(w)<bar>el<bar>exe "norm! *"<bar>en<cr>
60+
nnoremap <silent> * :let w=ThisMark()<bar>
61+
\if w!=""<bar>
62+
\cal search(w)<bar>
63+
\el<bar>
64+
\exe "norm! *"<bar>
65+
\en<cr>
5366
" jump to the previous occurrence of this mark
54-
nnoremap # :let w=ThisMark()<bar>if w!=""<bar>cal search(w,"b")<bar>el<bar>exe "norm! #"<bar>en<cr>
67+
nnoremap <silent> # :let w=ThisMark()<bar>
68+
\if w!=""<bar>
69+
\cal search(w,"b")<bar>
70+
\el<bar>
71+
\exe "norm! #"<bar>
72+
\en<cr>
5573
" mark or unmark a visual selection
56-
vnoremap \m "my:cal Mark("\\V".substitute(@m,"\\n","\\\\n","g"))<cr>
74+
vnoremap <silent> \m "my:cal Mark("\\V".substitute(@m,"\\n","\\\\n","g"))<cr>
5775
5876
" define variables if they don't exist
5977
function! InitMarkVaribles()
78+
if !exists("g:mwHistAdd")
79+
let g:mwHistAdd = "/@"
80+
endif
6081
if !exists("g:mwCycleMax")
6182
let i = 1
6283
while hlexists("MarkWord" . i)
@@ -105,7 +126,7 @@ function! Mark(...) " Mark(regexp)
105126
endif
106127
let i = i + 1
107128
endwhile
108-
return
129+
return 0
109130
endif
110131

111132
" clear the mark if it has been marked
@@ -114,14 +135,18 @@ function! Mark(...) " Mark(regexp)
114135
if regexp == b:mwWord{i}
115136
let b:mwWord{i} = ""
116137
exe "syntax clear MarkWord" . i
117-
return
138+
return 0
118139
endif
119140
let i = i + 1
120141
endwhile
121142

122143
" add to history
123-
call histadd("/", regexp)
124-
call histadd("@", regexp)
144+
if stridx(g:mwHistAdd, "/") >= 0
145+
call histadd("/", regexp)
146+
endif
147+
if stridx(g:mwHistAdd, "@") >= 0
148+
call histadd("@", regexp)
149+
endif
125150

126151
" quote regexp with / etc. e.g. pattern => /pattern/
127152
let quote = "/?~!@#$%^&*+-=,.:"
@@ -134,7 +159,7 @@ function! Mark(...) " Mark(regexp)
134159
let i = i + 1
135160
endwhile
136161
if i >= strlen(quote)
137-
return
162+
return -1
138163
endif
139164

140165
" choose an unused mark group
@@ -149,7 +174,7 @@ function! Mark(...) " Mark(regexp)
149174
endif
150175
exe "syntax clear MarkWord" . i
151176
exe "syntax match MarkWord" . i . " " . quoted_regexp . " containedin=ALL"
152-
return
177+
return i
153178
endif
154179
let i = i + 1
155180
endwhile
@@ -166,7 +191,7 @@ function! Mark(...) " Mark(regexp)
166191
endif
167192
exe "syntax clear MarkWord" . i
168193
exe "syntax match MarkWord" . i . " " . quoted_regexp . " containedin=ALL"
169-
return
194+
return i
170195
endif
171196
let i = i + 1
172197
endwhile

0 commit comments

Comments
 (0)