我的清单是:
[ 02 , 03 , 03 , 16 , 17 , 17 , 28 , 29 , 29 ]
我要知道,我如何能够从名单上删除这些重复之处。
Would it be also possible when I add an item to the list to check if the item is already in the list (to avoid duplicates?)
我的清单是:
[ 02 , 03 , 03 , 16 , 17 , 17 , 28 , 29 , 29 ]
我要知道,我如何能够从名单上删除这些重复之处。
Would it be also possible when I add an item to the list to check if the item is already in the list (to avoid duplicates?)
提 出
let list=[ 02 , 03 , 03 , 16 , 17 , 17 , 28 , 29 , 29 ]
let unduplist=filter(copy(list), index(list, v:val, v:key+1)==-1 )
。 关于第二个问题,见:h Index()
。
如果是,
那么,你或许应当使用假肢:对于大量探照相机,速度较快(实际上不需要)。
这种排位外法(即,在<代码>后生效:)的取代将消除复制件(条件是这些复制件是连续的):
s/( [0-9]+ ),s+1/1/g
您还可以将名单转换为一位理论家的钥匙:
let list=[ 02 , 03 , 03 , 16 , 17 , 17 , 28 , 29 , 29 ]
let dict = {}
for l in list
let dict[l] =
endfor
let uniqueList = keys(dict)
这既符合分类清单,也符合未经编辑的名单。
规定
uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
Remove second and succeeding copies of repeated adjacent
{list} items in-place. Returns {list}. If you want a list
to remain unmodified make a copy first: >
:let newlist = uniq(copy(mylist))
< The default compare function uses the string representation of
each item. For the use of {func} and {dict} see |sort()|.
Is it possible to update vim plugins automatically?
How can I configure vim to autowrite buffers after switching with alt-tab to another application?
I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....
I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...
How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...
I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...
Whenever I start a shell in vim using :sh, it doesn t source my ~/.bashrc file. How can I get it to do this automatically?
I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...