Skip to content

Suggestion: Add Support for More VS Code Variables in Run++ Extension #2

@minhkhang1008

Description

@minhkhang1008

Hi MdAlbinHossain,

I know you have released this extension for quite a long time but I just recently discovered your Run++ extension, and it has been a lifesaver for my competitive programming workflow. Thank you for creating such a helpful tool!

However, I noticed that the extension currently only supports the ${workspaceFolder} variable, which can be limiting when working with nested folder structures and varied file names. This makes it challenging to configure input and output file paths dynamically, especially for projects with multiple subfolders.

My Use Case

To give you a better idea, here’s an example of my project structure:

  • HocCpp (main workspace folder)
    • MathProblem (first-level subfolder)
      • Addiv (second-level subfolder)
        • Addiv.cpp (same name as the second-level subfolder)
        • Addiv.INP (input file)
        • Addiv.OUT (output file)
    • RealWorld (first-level subfolder)
      • QUALIFY (second-level subfolder)
        • QUALIFY.cpp
        • QUALIFY.INP
        • QUALIFY.OUT

In this structure, my .cpp, .INP, and .OUT files are located in deeply nested subfolders, and their names match the second-level subfolder (e.g., Addiv.cpp, QUALIFY.cpp). With only ${workspaceFolder} available, I have to hardcode paths like ${workspaceFolder}/RealWorld/QUALIFY/QUALIFY.INP, which isn’t scalable when working on multiple problems across different subfolders.

Suggestion

To make the extension more flexible and user-friendly, I suggest adding support for additional VS Code variables that are commonly used in task configurations. These variables would allow users to dynamically reference file paths and names, making the extension more versatile for competitive programming and other workflows with complex folder structures.

Here are the variables I recommend adding:

  • ${fileDirname}: Resolves to the directory of the currently active file. For example, if I’m working on HocCpp/RealWorld/QUALIFY/QUALIFY.cpp, this would resolve to HocCpp/RealWorld/QUALIFY/. This is particularly useful for locating .INP and .OUT files in the same directory as the .cpp file.
  • ${fileBasenameNoExtension}: Resolves to the name of the current file without its extension. For QUALIFY.cpp, this would resolve to QUALIFY. This is essential for matching input/output files (e.g., QUALIFY.INP, QUALIFY.OUT) to the source file name.
  • ${file}: Resolves to the full path of the current file (e.g., HocCpp/RealWorld/QUALIFY/QUALIFY.cpp). This can be helpful for custom commands that need the exact file path.
  • ${relativeFileDirname}: Resolves to the relative path of the file’s directory from the workspace folder (e.g., RealWorld/QUALIFY). This could be useful for constructing paths relative to the workspace root.

Example Configuration with Suggested Variables

With these variables, I could configure the Run++ settings like this:

  • Run: Input File: ${fileDirname}/${fileBasenameNoExtension}.INP
    • Resolves to HocCpp/RealWorld/QUALIFY/QUALIFY.INP for QUALIFY.cpp.
  • Run: Output File: ${fileDirname}/${fileBasenameNoExtension}.OUT
    • Resolves to HocCpp/RealWorld/QUALIFY/QUALIFY.OUT.
  • Run: Command: ${fileDirname}/${fileBasenameNoExtension} < ${fileDirname}/${fileBasenameNoExtension}.INP > ${fileDirname}/${fileBasenameNoExtension}.OUT
    • Dynamically runs the compiled program with the correct input/output redirection.

This setup would work seamlessly across all my subfolders without needing to hardcode paths for each problem.

Thank you

I am not sure if you would read this, but you should know that your work is incredible and it helps other people out there like me :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions