有插件显示标记,例如vim-signature和ShowMarks,但他们只在侧栏显示标志。
有没有办法突出显示有标记的所有行?
目前我正在使用表达式来执行此操作,例如:
:highlight currawong ctermbg=darkred guibg=darkred
:match currawong /\%12l\|\%34l\|\%5l/
这突出了第12,34和5行。
它有效但不太方便。
答案 0 :(得分:1)
请使用此命令:
a-d
它将突出显示包含标记的行:import sys
GameMatrix = [ ['S','E','A','N','T','A','R','C','I','T','R','U','R','T','O','I','I','Y'],
['O','C','U','P','O','N','A','P','S','A','N','D','D','U','N','E','R','L'],
['C','O','A','U','S','E','A','R','L','M','O','O','Y','N','O','S','I','N'],
['E','P','O','V','A','L','L','A','A','R','R','A','A','D','F','O','R','E'],
['D','R','F','L','R','D','R','Y','N','I','L','S','R','R','C','R','A','A'],
['V','A','L','L','E','Y','S','A','D','Y','H','U','M','A','T','A','P','E'],
['T','I','D','A','L','P','O','O','L','M','O','U','N','T','A','I','N','S'],
['D','R','J','O','D','D','C','O','R','A','L','R','E','E','F','N','S','E'],
['A','I','U','A','E','P','E','O','A','S','I','S','N','O','O','F','E','A'],
['N','E','N','S','S','O','A','S','R','I','S','L','A','C','A','O','A','F'],
['T','D','G','S','E','D','A','L','C','E','H','U','M','E','A','R','F','L'],
['A','E','L','D','P','I','I','T','T','A','O','L','A','K','E','E','L','O'],
['R','D','E','S','E','R','T','R','I','V','E','R','E','P','R','S','O','O'],
['C','P','I','C','E','I','D','O','C','E','A','N','P','O','L','T','H','R'],
['J','O','T','O','A','N','T','A','R','C','T','I','C','U','E','T','U','P'],
['U','N','U','S','A','N','D','D','U','O','A','G','R','A','S','S','M','O'],
['N','D','H','U','M','F','O','R','E','S','T','S','E','A','F','D','I','P'],
['V','A','L','L','R','E','T','I','D','A','L','P','T','I','D','A','D','I'],
]
wordSearch = {'antarctic','grass','oasis','sanddune','arctic','humid','ocean','sea','coralreef','island','pond','seafloor','desert','jungle','prairie','tidalpool','dry','lake','rainforest','tundra','forest','mountain','river','valley'}
def print_board(GameMatrix):
for i in range(0,len(GameMatrix)):
for j in range(0,len(GameMatrix[i])):
sys.stdout.write(GameMatrix[i][j])
sys.stdout.write(' ')
print
def word_going_right(GameMatrix,wordSearch,row,col):
i = 0
f = 0
v = True
while v == True:
if wordSearch[i] == GameMatrix[row][col]:
f += 1
if f == len(wordSearch):
v = True
break
if wordSearch[i] != GameMatrix[row][col]:
v = True
break
i += 1
f += 1
if col >= len(GameMatrix[0]):
v = False
break
return v
def word_going_left(Gamematrix,wordSearch,row,col):
i = 0
f = 0
v = True
while v == True:
if wordSearch[i] == GameMatrix[row][col]:
f += 1
if f == len(wordSearch):
v = True
break
if wordSearch[i] != GameMatrix[row][col]:
v = False
break
i += 1
f += 1
col -= 1
if col <= 0:
v = False
break
return v
def word_going_up(GameMatrix,wordSearch,row,col):
i = 0
f = 0
v = True
while v == True:
if wordSearch[i] == GameMatrix[row][col]:
f += 1
if f == len(wordSearch):
v = True
break
if wordSearch[i] != GameMatrix[row][col]:
v = False
break
i += 1
f += 1
row -= 1
if row <= 0:
v = False
break
return v
def word_going_down(GameMatrix,wordSearch,row,col):
i = 0
f = 0
v = True
while v == True:
if wordSearch[i] == GameMatrix[row][col]:
f += 1
if f == len(wordSearch):
v = True
break
if wordSearch[i] != GameMatrix[row][col]:
v = False
break
i += 1
row += 1
if row >= len(GameMatrix):
v = False
break
return v
def find_word_in_puzzle(GameMatrix,wordSearch):
value = True
new_row = 0
new_col = 0
direction = ''
for r in range(0,len(GameMatrix)):
for c in range(0,len(GameMatrix)):
if word_going_right(GameMatrix,wordSearch,r,c) == True:
new_row = r
new_col = c
direction = 'right'
value = True
break
if word_going_left(GameMatrix,wordSearch,r,c) == True:
new_row =r
new_col = c
direction = 'left'
value = True
break
if word_going_up(GameMatrix,wordSearch,r,c) == True:
new_row = r
new_col = c
direction = 'up'
value = True
break
if word_going_down(GameMatrix,wordSearch,r,c) == True:
new_row = r
new_col = c
direction = 'down'
value = True
break
if value == False:
print "%s can't be found" % (wordSearch)
if __name__ == '__main__':
print GameMatrix
print
print_board(GameMatrix)
print
words_filename = raw_input("Enter the word= ")
print wordSearch
print
for line in words_filename:
word = line.strip()
find_word_in_puzzle(GameMatrix, wordSearch)
键入 F5 以强制重绘。