I'm trying to make a function to insert license header from external file on first line in the buffer. The script is:
fun InsertLicense() if filereadable('LICENSE') let license = 'LICENSE' elseif filereadable('LICENSE.txt') let license = 'LICENSE.txt' else let license = '' endif if line('$') < 3 && len(license) > 0 echo 'inserting license from ' . license call append(0, readfile(license)) endif endfun
It's working fine except one problem:
LICENSE file is a plaintext file, e.g.:
Copyright 2019 OrgName Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated ...
but I need to wrap it as Java multiline comment:
/* * Copyright 2019 OrgName * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated ... */
Is it possible to insert
* before each line of
license file using vim scripting language?