Get the file name without file extension in Vim function.

前端 未结 4 642
梦毁少年i
梦毁少年i 2021-01-30 10:51

I want to get the file name without the file extension in Vim.

I wrote the following functions in my .vimrc file for compile and run the Java program.

4条回答
  •  盖世英雄少女心
    2021-01-30 11:19

    :help expand() should give you the answer, see expand().

    You should use the r modifier for %, with %:r instead of % to get the file name without extension.

    If you want to write functions to build and execute files, you should also have a look at the documentation for shellescape, in order to prevent problems with spaces in file name or path.

提交回复
热议问题