Reputation: 288
I'm trying to make a function to open a specified Project Euler problem. Here's what I have:
function ProjectEuler ()
let problem = input('Enter problem number: ')
cd /Users/me/Documents/Computer_Stuff/Code/Project_Euler
e fnamemodify('problem'.problem.'.py', ':p')
endfunction
fnamemodify() gives the correct filepath to any problem I enter, so my thinking was that e
would then open the file at that filepath, but instead it opens /Users/me/Documents/Computer_Stuff/Code/Project_Euler/fnamemodify('problem'.problem.'.py', ':p')
.
Does anyone know what I'm doing wrong?
Upvotes: 1
Views: 315
Reputation: 196476
You must use :execute
to use variables or expressions in a mapping or command.
execute "edit " . fnamemodify('foo.txt', ':p')
Upvotes: 2