admin管理员组文章数量:1024593
I have a task that I do several times a day everyday that requires editing 20 files (spread out in different places throughout my project), keeping them open since editing each file mostly requires referring back to 1 or several of the other files multiple times.
I want to create a shortcut that opens these 20 files at once so that I can edit them, without navigating to the location of each file, as this becomes slightly tedious due to how often I have to do this task.
However, I frequently use the preview mode when coding & so don't want to disable preview mode altogether via setting "workbench.editor.enablePreview": false
in my settings file.
I also don't want to relocate the files into 1 place, as this would break the general anisation of the project - unless there's a way to create an alias/shortcut of a file in a different location, that can open the file while not moving the actual file from its original location.
I used the top answer from this question to create the below macro. However, this macro only opens each file in preview mode - every time the next file is opened, the previous file is closed, & so the macro essentially only opens the last file in preview mode.
const vscode = require('vscode');
module.exports.macroCommands = {
OpenFrequentFiles: {
no: 1,
func: () => openFrequentFiles()
},
};
function openFrequentFiles() {
const workspaceDir = ""/full/path/to/my/workspace"
const frequentFilepaths = [
"path/to/file1",
"path/to/file2",
...
"path/to/file20",
]
for (let i = 0; i < frequentFilepaths.length; i++) {
fullFilepath = workspaceDir + '/' + frequentFilepaths[i];
openFile(fullFilepath);
}
}
function openFile(filename) {
const document = vscode.workspace.openTextDocument(filename);
const editor = vscode.window.showTextDocument(document);
}
Is there are way to open the files & keep them open, instead of only opening each one briefly in period mode? I've looked through & tried to write something along the lines of workbench.action.keepEditor
, but I haven't managed to make it work.
Or any other suggestions would be great - it would just save me time & tedium in the long term if I could automate the opening of these files without navigating to each one.
I have a task that I do several times a day everyday that requires editing 20 files (spread out in different places throughout my project), keeping them open since editing each file mostly requires referring back to 1 or several of the other files multiple times.
I want to create a shortcut that opens these 20 files at once so that I can edit them, without navigating to the location of each file, as this becomes slightly tedious due to how often I have to do this task.
However, I frequently use the preview mode when coding & so don't want to disable preview mode altogether via setting "workbench.editor.enablePreview": false
in my settings file.
I also don't want to relocate the files into 1 place, as this would break the general anisation of the project - unless there's a way to create an alias/shortcut of a file in a different location, that can open the file while not moving the actual file from its original location.
I used the top answer from this question to create the below macro. However, this macro only opens each file in preview mode - every time the next file is opened, the previous file is closed, & so the macro essentially only opens the last file in preview mode.
const vscode = require('vscode');
module.exports.macroCommands = {
OpenFrequentFiles: {
no: 1,
func: () => openFrequentFiles()
},
};
function openFrequentFiles() {
const workspaceDir = ""/full/path/to/my/workspace"
const frequentFilepaths = [
"path/to/file1",
"path/to/file2",
...
"path/to/file20",
]
for (let i = 0; i < frequentFilepaths.length; i++) {
fullFilepath = workspaceDir + '/' + frequentFilepaths[i];
openFile(fullFilepath);
}
}
function openFile(filename) {
const document = vscode.workspace.openTextDocument(filename);
const editor = vscode.window.showTextDocument(document);
}
Is there are way to open the files & keep them open, instead of only opening each one briefly in period mode? I've looked through https://code.visualstudio/api/references/vscode-api & tried to write something along the lines of workbench.action.keepEditor
, but I haven't managed to make it work.
Or any other suggestions would be great - it would just save me time & tedium in the long term if I could automate the opening of these files without navigating to each one.
Share Improve this question asked Nov 18, 2024 at 11:35 domgunewardenadomgunewardena 12 bronze badges 2- you can use the extension I wrote: File Group – rioV8 Commented Nov 18, 2024 at 12:27
- Exactly what I was looking for @rioV8 - thanks so much! – domgunewardena Commented Nov 18, 2024 at 14:07
1 Answer
Reset to default 0Answer provided by @rioV8 in comments - File Group extension allows creating groups of files that can be opened (& kept opened) simultaneously.
I have a task that I do several times a day everyday that requires editing 20 files (spread out in different places throughout my project), keeping them open since editing each file mostly requires referring back to 1 or several of the other files multiple times.
I want to create a shortcut that opens these 20 files at once so that I can edit them, without navigating to the location of each file, as this becomes slightly tedious due to how often I have to do this task.
However, I frequently use the preview mode when coding & so don't want to disable preview mode altogether via setting "workbench.editor.enablePreview": false
in my settings file.
I also don't want to relocate the files into 1 place, as this would break the general anisation of the project - unless there's a way to create an alias/shortcut of a file in a different location, that can open the file while not moving the actual file from its original location.
I used the top answer from this question to create the below macro. However, this macro only opens each file in preview mode - every time the next file is opened, the previous file is closed, & so the macro essentially only opens the last file in preview mode.
const vscode = require('vscode');
module.exports.macroCommands = {
OpenFrequentFiles: {
no: 1,
func: () => openFrequentFiles()
},
};
function openFrequentFiles() {
const workspaceDir = ""/full/path/to/my/workspace"
const frequentFilepaths = [
"path/to/file1",
"path/to/file2",
...
"path/to/file20",
]
for (let i = 0; i < frequentFilepaths.length; i++) {
fullFilepath = workspaceDir + '/' + frequentFilepaths[i];
openFile(fullFilepath);
}
}
function openFile(filename) {
const document = vscode.workspace.openTextDocument(filename);
const editor = vscode.window.showTextDocument(document);
}
Is there are way to open the files & keep them open, instead of only opening each one briefly in period mode? I've looked through & tried to write something along the lines of workbench.action.keepEditor
, but I haven't managed to make it work.
Or any other suggestions would be great - it would just save me time & tedium in the long term if I could automate the opening of these files without navigating to each one.
I have a task that I do several times a day everyday that requires editing 20 files (spread out in different places throughout my project), keeping them open since editing each file mostly requires referring back to 1 or several of the other files multiple times.
I want to create a shortcut that opens these 20 files at once so that I can edit them, without navigating to the location of each file, as this becomes slightly tedious due to how often I have to do this task.
However, I frequently use the preview mode when coding & so don't want to disable preview mode altogether via setting "workbench.editor.enablePreview": false
in my settings file.
I also don't want to relocate the files into 1 place, as this would break the general anisation of the project - unless there's a way to create an alias/shortcut of a file in a different location, that can open the file while not moving the actual file from its original location.
I used the top answer from this question to create the below macro. However, this macro only opens each file in preview mode - every time the next file is opened, the previous file is closed, & so the macro essentially only opens the last file in preview mode.
const vscode = require('vscode');
module.exports.macroCommands = {
OpenFrequentFiles: {
no: 1,
func: () => openFrequentFiles()
},
};
function openFrequentFiles() {
const workspaceDir = ""/full/path/to/my/workspace"
const frequentFilepaths = [
"path/to/file1",
"path/to/file2",
...
"path/to/file20",
]
for (let i = 0; i < frequentFilepaths.length; i++) {
fullFilepath = workspaceDir + '/' + frequentFilepaths[i];
openFile(fullFilepath);
}
}
function openFile(filename) {
const document = vscode.workspace.openTextDocument(filename);
const editor = vscode.window.showTextDocument(document);
}
Is there are way to open the files & keep them open, instead of only opening each one briefly in period mode? I've looked through https://code.visualstudio/api/references/vscode-api & tried to write something along the lines of workbench.action.keepEditor
, but I haven't managed to make it work.
Or any other suggestions would be great - it would just save me time & tedium in the long term if I could automate the opening of these files without navigating to each one.
Share Improve this question asked Nov 18, 2024 at 11:35 domgunewardenadomgunewardena 12 bronze badges 2- you can use the extension I wrote: File Group – rioV8 Commented Nov 18, 2024 at 12:27
- Exactly what I was looking for @rioV8 - thanks so much! – domgunewardena Commented Nov 18, 2024 at 14:07
1 Answer
Reset to default 0Answer provided by @rioV8 in comments - File Group extension allows creating groups of files that can be opened (& kept opened) simultaneously.
本文标签:
版权声明:本文标题:vscode extensions - Create a shortcut to open multiple files and keep them open in Visual Studio Code - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745621038a2159572.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论