vimrc - Can vim realize the complex requirement of automatically detecting jpg files in the working directory and then automatically filling in the content based on the number of files?
PHPz2017-05-16 16:34:42
0
2
660
My requirement is to detect the images in the working directory, and then fill in the corresponding img tags into page.html. Just like the effect I manually had.
You don’t know how to use your own brain.
…wait, you’re Windows? Then I will just say that the idea is good.
Read in the file list. For example, you can use the
!r ls *.jpg
来读。Windows 上自己想办法。如果你没办法通过外部命令获取文件名列表,也可以试试 Vim 的glob()
function under Linux.Ctrl-V Enter column block visual mode and write the same part in front of the file name (select the beginning and press I)
This step is not very intuitive. Use V to enter line selection, then press
:s/$/..../
to append characters at the end with replaceOf course you can also use substitution in step 2.
There is also a plug-in called visincr, which is very suitable for generating this kind of numerical sequence.
This is the purpose of HTML template engines and various front-end construction tool chains. . . . .
vim is possible, but it is not recommended because you still need to update it manually