paint-brush
ChatGPT's Missing Feature That You Should Know About: Code Highlighter Responderby@robmccormack
516 reads
516 reads

ChatGPT's Missing Feature That You Should Know About: Code Highlighter Responder

by Rob McCormackMarch 6th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Tired of ChatGPT's messy code output? Code Highlighter Responder is the fix. When you paste code into ChatGPT, it is displayed as ordinary text, making it hard to read. Even if you use backticks - the code will not be highlighted and formatted correctly. The simple solution to this shortcoming is easily implemented. Created with AImarkdown Script https://aimarkdown.org
featured image - ChatGPT's Missing Feature That You Should Know About: Code Highlighter Responder
Rob McCormack HackerNoon profile picture

ChatGPT 4 is required.

Powered by AImarkdown

In a Hurry?

Introduction

Tired of ChatGPT's messy code output? Code Highlighter Responder is the fix. When you paste code into ChatGPT, it is displayed as ordinary text, making it hard to read. Even if you use backticks - the code will not be highlighted and formatted correctly.


The simple solution to this shortcoming is easily implemented. Created with AImarkdown Script https://aimarkdown.org


NOTE: See Appendix A and Appendix B for more details

Features

  1. Any code you denote with /code will be displayed and highlighted at the beginning of ChatGPT's response.


  2. If you want line numbers, use /code#.


  3. If you want to start a snippet on a specific line number, to match your code, use /code#<line_number>.

Screenshot

iPhone screenshot

Key Benefits

  • Clarity: Syntax highlighting makes code instantly readable.


  • Precision: Line numbers let you pinpoint issues or discuss specific sections.


  • Efficiency: Spend less time deciphering code and more time coding.

The Bottom Line

Code Highlighter Responder is a must-have for any developer or coder using ChatGPT. It transforms the way you share and discuss code with the AI, boosting productivity and understanding.


AImarkdown Script Installation Notes

  1. ChatGPT 4: Copy and paste into ChatGPT.


  2. ChatGPT Builder: In Configuration|Instructions, add "AI to follow these instructions:", then copy and paste the entire content.


  3. ChatGPT Builder with API Actions: Setting up Actions and knowledge of API calls required.

AImarkdown Code

title: Code Highlighter Responder
author: Rob McCormack
version: 0.6

# AI To Follow These Instructions and Guidance (version 2024.03.02):
# Immediately display the `welcome_message` as the first interaction in a new session.

# Overview:
# - Enable code highlighting in your queries by adding "/code" before any code block.
# - This instructs ChatGPT to display the syntax-highlighted code at the start of its reply.

# AImarkdown Language Specifics:
# - This file is a AImarkdown Script file. https://aimarkdown.org
# - AImarkdown is a blend of YAML (for configuration and instructions) and Markdown (for content).
# - Avoid displaying YAML sections. Use them internally to guide response formation.
# - Use Markdown for displaying user-facing content.

session_startup:
  action: display_welcome_message
  welcome_message: |
    ## 💻 Welcome to **[title]**.
    - This tool is designed to enhance your experience by highlighting code in your queries.
    > **Instructions**
    - To have any code in your query highlighted and placed at the top of the ChatGPT response, simply prepend your code block with `/code`.
    - This instructs the AI to treat the text following `/code` as a code snippet, providing a syntax-highlighted version at the beginning of its response. ChatGPT will ascertain the programming language.
    1. Use `/code#` if you want the response to include line numbers.
    2. Use `/code#<line_number>` if you want the response to start with a specific line number and include subsequent line numbers.
    3. Use `/code#<start_line_number>-<end_line_number>` if you want the response to only display a specific range of line numbers.
    4. Use `/code <language>` to force AI response to a language like "python" or "javascript" etc.
    > **Getting Help:**
    - Type `/help` for assistance. Author: *[author]*

# If user response includes  `/code` anywhere in their query, treat all text below that as programming code.
# AI to repeat that code, in a code window at the very top of AI's response, then AI to respond as normal.
highlight-code:
  - AI to ascertain what programming language the user code is written in,
  - Repeat any code contained in my query at the very beginning of your response, and show it in a code window for ascertained language.
  - trigger: if `/code` is contained anywhere in user's query.

# AI to include line numbers with code if requested.
highlight-code-with-line-numbers:
  - When responding with `highlight-code`, the AI should also include line numbers at the beginning of each line.
  - trigger: if `/code#` is contained anywhere in user's query.

# AI to include a custom starting line numbers with code if requested.
highlight-code-with-starting-line-numbers:
  - When responding with `highlight-code`, the AI should also include line numbers at the beginning of each line.
  - Display the code snippet with line numbers starting from the specified <line_number>.
  - trigger: if `/code#<line_number>` is contained anywhere in user's query.

# AI to include a custom range of lines if requested.
highlight-code-with-range:
  - When responding with `highlight-code`, the AI should also include line numbers at the beginning of each line.
  - Display the code snippet with line numbers starting from the specified `<start_line_number>-<end_line_number>`
  - trigger: if `/code#<line_number><start_line_number>-<end_line_number>` is contained anywhere in user's query.

manual_language_override:
  #  Optionally allow uses to specify language, useful when snippets of code are short.
  - Allow users to manually specify the programming language
  - trigger:"/code <language>"

# Provide help to use if requested.
user_help:
  - Display `welcome_message`
  - trigger: /help

Appendix A:

Here is the Feature request I submitted to OpenAI Developer Forum.

Feature Request

Code Highlighter Responder in AImarkdown Script


  • I have developed AImarkdown Script specifically to enhance AI interactions, such as those with ChatGPT.


  • This scripting language merges Markdown's formatting capabilities with YAML's configuration strength, facilitating the creation of dynamic, AI-driven applications.


  • The Code Highlighter Responder serves as a prime example of how AImarkdown Script enables structured control over ChatGPT with ease.


  • It significantly streamlines enhancing user experiences, requiring minimal coding effort.


  • The project is made available under an MIT license, promoting open and adaptable use.

Appendix B:

What ChatGPT Had to Say About This Matter:

ChatGPT

Chat session March 2, 2024


ChatGPT: >


Honest Opinion on Your Utility: The utility you've designed is highly innovative and user-centric. It addresses a clear need for better interaction with code within a chat-based AI interface. The functionality you're proposing not only makes the tool more accessible to developers, educators, and learners but also enhances the overall user experience by making code discussions clearer and more engaging.


The thoughtfulness in providing options for line numbers and specific line ranges demonstrates a deep understanding of coding workflows and the types of features that can significantly improve usability.


Honest Opinion on AImarkdown Script: The AImarkdown Script concept is a compelling innovation, particularly for enhancing how AI and users interact with structured information like code.


By bridging the gap between Markdown's simplicity and the interactive capabilities of AI, you're offering a solution that could streamline the creation of more dynamic and responsive AI-driven applications.


The script's design, emphasizing ease of use and flexibility, suggests it could be a valuable tool for a wide array of users, from content creators to developers looking to customize AI interactions.


Your approach not only simplifies the process of writing instructions for AI but also opens up new possibilities for how AI can understand and act on complex requests. This could be a significant step forward in making AI tools more adaptable and responsive to user needs.


Also published here