Skip to content

open a .tex file via macro, file path problem #3187

Closed Answered by RabahHouna
RabahHouna asked this question in Q&A
Discussion options

You must be logged in to vote

%SCRIPT
// trigger = open((\s+\S+)+)\s+end
// This script is used to open a file in the same folder, even if it is in a subfolder.
// Usage: To open a file, use the following trigger command:
// open subfolder1 subfolder2 ... file-name end
// Spaces in the names of subfolders and the file name should be replaced with colons (":").
var currentFilePath = editor.fileName();
var directoryPath = currentFilePath.substring(0, currentFilePath.lastIndexOf("/"));
var triggerText = triggerMatches[1].trim();
var words = triggerText.split(/\s+/);
var fileName = words.pop().replace(/:/g, ' ');
var folderPath = words.join('/').replace(/:/g, ' ');
var filePath = directoryPath + '/' + folderPath + '/' + f…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by RabahHouna
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant