How to add "# " to head of the file name put in vim?

Viewed 65

I try to use this command to write down my file name when I press the binding key.

:put!=expand('%:t:r')

I want to improve it

Because I only use this command while I am writting markdown.

So I want to add "#" and " " to the head of the file name

I try a lot but didn't works, so how can I achieve.

1 Answers

you can use the "concatenate strings" operator . to prepend '# ' (or whatever string you want) to the expanded filename:

:put = '# ' . expand('%:t:r')
Related