1
1
" Script Name: mark.vim
2
- " Version: 1.1.2
2
+ " Version: 1.1.4
3
3
" Last Change: March 23, 2005
4
4
" Author: Yuheng Xie <[email protected] >
5
5
"
@@ -43,20 +43,41 @@ hi MarkWord6 ctermbg=Blue ctermfg=Black guibg=#9999FF guifg=Black
43
43
" you may map keys to call Mark() in your vimrc file to trigger the functions.
44
44
" examples:
45
45
" 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>
47
50
" 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>
49
57
" 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>
51
59
" 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>
53
66
" 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>
55
73
" 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>
57
75
58
76
" define variables if they don't exist
59
77
function ! InitMarkVaribles ()
78
+ if ! exists (" g:mwHistAdd" )
79
+ let g: mwHistAdd = " /@"
80
+ endif
60
81
if ! exists (" g:mwCycleMax" )
61
82
let i = 1
62
83
while hlexists (" MarkWord" . i )
@@ -105,7 +126,7 @@ function! Mark(...) " Mark(regexp)
105
126
endif
106
127
let i = i + 1
107
128
endwhile
108
- return
129
+ return 0
109
130
endif
110
131
111
132
" clear the mark if it has been marked
@@ -114,14 +135,18 @@ function! Mark(...) " Mark(regexp)
114
135
if regexp == b: mwWord {i }
115
136
let b: mwWord {i } = " "
116
137
exe " syntax clear MarkWord" . i
117
- return
138
+ return 0
118
139
endif
119
140
let i = i + 1
120
141
endwhile
121
142
122
143
" 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
125
150
126
151
" quote regexp with / etc. e.g. pattern => /pattern/
127
152
let quote = " /?~!@#$%^&*+-=,.:"
@@ -134,7 +159,7 @@ function! Mark(...) " Mark(regexp)
134
159
let i = i + 1
135
160
endwhile
136
161
if i >= strlen (quote)
137
- return
162
+ return -1
138
163
endif
139
164
140
165
" choose an unused mark group
@@ -149,7 +174,7 @@ function! Mark(...) " Mark(regexp)
149
174
endif
150
175
exe " syntax clear MarkWord" . i
151
176
exe " syntax match MarkWord" . i . " " . quoted_regexp . " containedin=ALL"
152
- return
177
+ return i
153
178
endif
154
179
let i = i + 1
155
180
endwhile
@@ -166,7 +191,7 @@ function! Mark(...) " Mark(regexp)
166
191
endif
167
192
exe " syntax clear MarkWord" . i
168
193
exe " syntax match MarkWord" . i . " " . quoted_regexp . " containedin=ALL"
169
- return
194
+ return i
170
195
endif
171
196
let i = i + 1
172
197
endwhile
0 commit comments