Can vim automatically detect jpg files in the working directory and then automatically populate the contents according to the number of files?

  question, vim

clipboard.png

My requirement is to check the pictures in the working directory and then go topage.htmlFill in the correspondingimgLabel. Just like meManualThe effect of playing up.

You can’t think for yourself.

…… Wait, are you Windows? Then I’ll just say the train of thought.

  1. Read in the file list. For example, it can be used under Linux! r ls *.jpgRead it. Do something about it on Windows. If you can’t get the list of file names through external commands, you can also try Vim’sglob()Function.

  2. Ctrl-VEnter the column block visual mode, write the same part in front of the file name (select the beginning and pressI)

  3. This step is not very intuitive. UseVEnter the row selection and press:s/$/..../Append characters to the tail by substitution.

Of course, you can also replace step 2.

In addition, there is a plug-in called visincr, which is very suitable for generating this numerical sequence.