Skip to content

a simple shell script to convert a piece of code to vscode snippet

License

Notifications You must be signed in to change notification settings

biochunan/Convert2vscSnippet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert2vscSnippet

A simple shell script to convert a piece of code to vscode snippet

Installation

pip install git+https://github.com/biochunan/Convert2vscSnippet

Usage

Grant execution permission

chmod +x convert2snippet.sh 

For small pieces of code, use the interactive version

./convert2snippet.sh
Enter text (Ctrl-D to finish):
RUN conda install pandas 
"RUN conda install pandas ",

For big chunk of code, use a file as input save the following as a file with random name e.g. raw

# Default to root only access to the Docker socket, set up non-root init script
RUN touch /var/run/docker-host.sock \
    && ln -s /var/run/docker-host.sock /var/run/docker.sock \
    && apt-get update \
    && apt-get -y install socat

pass the file location to the script

./convert2snippet.sh raw 

stdout:

"# Default to root only access to the Docker socket, set up non-root init script",
"RUN touch /var/run/docker-host.sock \\",
"    && ln -s /var/run/docker-host.sock /var/run/docker.sock \\",
"    && apt-get update \\",
"    && apt-get -y install socat",

These are ready to place inside vscode snippet json file

Open vscode Command Palette, use the key combination Cmd + Shift + P (on Mac), Ctrl + Shift + P (Windows). Search for snippet

Then select Preferences: Configure User Snippets and select the language you want to add the snippet to or create a new one.

About

a simple shell script to convert a piece of code to vscode snippet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published