Get name of the current file in Vim

后端 未结 6 1449
清歌不尽
清歌不尽 2020-12-14 00:52

I\'m trying to find the name of the file I\'m editing inside of Vim. So I can use it to map F5 to compile this file. Would of course be great if I could recognize

6条回答
  •  攒了一身酷
    2020-12-14 01:45

    As others have already mentioned, % is expanded to the current file. If you want to get that string in vim script, use expand("%").

    But you may want to simply set makeprg to something like "compiler-command\ %" and run :make - you gain quick-fix support that way. (open errors/warnings window with :copen)

提交回复
热议问题