I am getting nothing in return for the
tempname() function in Vim. More specifically, I kept getting only ".do" assigned to the variable
temp using the following statement.
let temp = tempname() . ".do"
The complete function that fails to get itself a "temp name":
let selectedLines = getbufline('%', line("'<"), line("'>")) if col("'>") < strlen(getline(line("'>"))) let selectedLines[-1] = strpart(selectedLines[-1], 0, col("'>")) endif if col("'<") != 1 let selectedLines = strpart(selectedLines, col("'<")-1) endif let temp = tempname() . ".do" call writefile(selectedLines, temp) " *** CHANGE PATH AND NAME TO REFLECT YOUR SETUP. USE \\ INSTEAD OF \ *** exec "!start C:\\Vim\\vimfiles\\ftplugin\\Stata-Vim-Suite\\rundo.exe " . temp " Delete the temp file after Vim closes au VimLeave * exe "!del -y" temp
(The above codeblock is supposed to be the body of function define with
fun! RunDoLines()on line-1, and
endfunon the last line.
This functions has been running very well for years, and it was only today that it should have failed on both of my Windows machines. (I use this function to send commands from Vim to the terminal of a statistical software.)
Things that I tried, but did not work
- I followed the instruction on the this page (vim.wikia), but
tempname()still gets me an empty string.
- Additionally, here goes the error message I get when trying to run
PlugInstallthrough Vim-Plug. I think this should also be related with my setting for the TEMP files.
Minimal replication case:
Issuing the following set of commands does not get me any output.
:let temp_file = tempname() :echo temp_file
Here goes a screenrecord demonstrating the problem: