I'm new to Vim, and I want to create a Vim function to make a CMake file.
It doesn't work, and I don't know how should I do it, so the relevant part of my code is:
function! CMake_CV()
let @d=@%:t
:split CMakeLists.txt<CR>iproject( <Esc>"dpi )<CR><Esc>:wq<CR>
endfunction
It is supposed to copy the name of the current file without the extension to a variable, and then copy it to the new file and save and close it.
It says, that @%:t is an invalid expression, and that only one file name is allowed.
Thanks!
Well, I solved the problem.
let @d=expand('%:t')
:split CMakeLists.txt
execute "normal i" "project( ".@d ")"
.
.
.
execute "normal gg=G"
execute ":wq"
I didn't know the execute command.