I'm trying to create a script that helps creating shebangs (Ok, it may not be that useful but has advantages when you don't know where the program is, for example), here's what I have so far:
function! CreateShebang()
call inputsave()
let program = input('Enter the program name: ')
call inputrestore()
let path = system('which ' . program)
call append(0, '#!' . path)
endfunction
By the way, I'm just starting with vim scrips, so if you notice any wrong function and concepts or know a better way to achieve the result, please tell me. Any help is really appreciated.
The big problem is that after running, the scripts prompts for the program name correctly and then add something like this to the file:
#!/usr/bin/perl^@
What's that ^@
doing there?
Also, If I may ask another question here, how can I clear the command line after input()
? The text entered by the user keeps showing until another command is entered.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…