claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Suggestion: Better ergonomics for long text

Open aud opened this issue 9 months ago • 12 comments

Deleting/editing text after input:

Reproduction:

  • Enter in a bunch of text
  • See that it inserted a placeholder ([Pasted text +11] for eg).
  • If you try to edit that, or if you're pasting in multiple blocks, it's non-obvious how to handle and breaks the insertion if you edit that special text directly.

Suggestions:

  • Don't do smart truncation.
  • If truncation is non-negotiable, make [Pasted line +linecnt] some sort of special token that when you edit your prompt, it won't allow you to edit individual chars and instead force you to delete the whole token (thus deleting the text).
$ claude
╭────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview!         │
│                                                    │
│   /help for help                                   │
│                                                    │
│   cwd: /Users/elliot/src/github.com/WithPage/page  │
╰────────────────────────────────────────────────────╯

> This is a really long text file
  This is a really long text file
  This is a really long text file
  This is a really long text file
  [Pasted text +35

⏺ I need to help you with a text file, but I don't see an actual file that was pasted. Could you please share the file again or tell me what you'd like me to do with it?

\ to insert a newline is a bit awkward

Almost like this needs an insert vs. command mode, similar to the bash mode. If you can be inserted into edit mode and go wild on the prompt. Another idea could be to allow some sort of swapping configuration away from \ to something a bit more fluid like cmd+enter.

aud avatar Feb 26 '25 16:02 aud

The first part is interesting feedback, thanks! We'll discuss our options here.

For the second part, are you using iTerm? If so, you can run /terminal-setup and we'll automatically map Shift+Enter to newline. Would that work for you? Your idea of insert vs. command mode is interesting as well!

ashwin-ant avatar Feb 26 '25 17:02 ashwin-ant

Thanks for looking! I'm using ghostty, not sure if there's an equivalent.

aud avatar Feb 26 '25 18:02 aud

For an insert mode it could be as simple as @ to enter insert mode (similar to bash mode) that gives you more predictable text editing rules (like enter = newline).

aud avatar Feb 26 '25 19:02 aud

M-Enter (esc followed by enter) would be also accepted for a new line in multi line. (like aider) CTRL-J could also be accepted for a new line multi line. (like charmbracelet's gum cli tool)

roychri avatar Feb 26 '25 19:02 roychri

Maybe /editor for opening in $EDITOR (like git commit msgs?)

darinkishore avatar Feb 27 '25 16:02 darinkishore

+100 this. Entering mulit-line text in terminal is painful (WSL FWIW).

Even ctrl+enter to move to next line would be an improvment!

m4dc4p avatar Mar 01 '25 20:03 m4dc4p

Maybe /editor for opening in $EDITOR (like git commit msgs?)

A shortcut to open up the prompt in temporary $EDITOR window would be super awesome. For me that would be Neovim. In Lazygit when writing a commit I can press Ctrl-o e and I have the ability to edit the git commit message in a normal sized, temporary Neovim Buffer. On :wq it will close and commit. This type of flow would be super awesome for Claude Code.

There are already Vim Keybindings for the prompt itself, but I can't really do much with it, since pressing Esc to enter Normal Mode conflicts with quiting claude entierly. This issue is already mentioned here: #39.

I am also using Ghostty and Mac btw. I did not get the M-Enter to work. I am just escaping it for every enter.. \<Enter>.

nikbrunner avatar Mar 02 '25 08:03 nikbrunner

#138 and #143 are near dupes.

peterkaminski avatar Mar 09 '25 16:03 peterkaminski

New claude code user here. Not sure the best issue to put this, but on the multi-line support: this was one of the first things I looked for in the docs. I'm coming from Aider, which I found awkward for anything more than short single-line prompts, until I found its multi-line mode, which was a huge improvement.

It looks there are various dupes and feature requests for better multi-line support, or issues with the /terminal-setup solution, including: https://github.com/anthropics/claude-code/issues/138, https://github.com/anthropics/claude-code/issues/729, https://github.com/anthropics/claude-code/issues/1863 and https://github.com/anthropics/claude-code/issues/1203.

From my POV, how Aider handles it is totally fine and aligned with UX conventions:

  • Enter submits the prompt by default, ie. maintains the current behaviour (I think https://github.com/anthropics/claude-code/issues/729 was closed because it suggests changing defaults).
  • There's a config option to change this so that enter will insert a newline, and another binding will submit the prompt. Aider uses M-Enter for this binding.
  • If you really want complex text edits, there's an additional binding to open $EDITOR.

It would be great to have one chosen issue for tracking this feature request, as there's clearly some desire for it!

mattduck avatar Jun 15 '25 07:06 mattduck

M-Enter (esc followed by enter) would be also accepted for a new line in multi line. (like aider) CTRL-J could also be accepted for a new line multi line. (like charmbracelet's gum cli tool)

M in terminal can be mapped to option (alt), but then many keys become disabled in international keyboards, like @ or #

eduo avatar Jun 17 '25 12:06 eduo

Was the /terminal-setup removed? It doesn't seem to be an available command for me with v1.0.31.

sangaline avatar Jun 21 '25 17:06 sangaline

I hope this feature must consider the usage environment of Windows users!!!!! I don't know why support is the worst when over 90% of programmers are Windows users!!!

eefan000 avatar Jun 22 '25 05:06 eefan000

✅ Citations Implementation Complete

The end-to-end citation flow is now fully operational in us-east-1. All AI services are collecting citations, and the data pipeline is successfully storing them in the Aurora database.

What Was Implemented

1. Database Migration (us-east-1)

  • Added 9 citation columns to ai_model_responses table
  • Created 5 indexes for efficient citation queries
  • Created 3 PostgreSQL helper functions for citation analysis
  • Created 3 analysis views for Equal Experts citation tracking

2. Data Flattener Updates

  • Updated aurora_flattener_lambda.py to extract 5 citation fields from S3 results
  • Fixed handling of empty string values for citation_quality_score (converts to NULL)
  • Files: scripts/aws/data_flattener/aurora_flattener_lambda.py (lines 297-304)

3. Database Client Updates

  • Updated aurora_data_api_client.py to include citation columns in INSERT statements
  • Properly handles JSONB for citations array and DECIMAL for citation_quality_score
  • Files: scripts/aws/data_flattener/aurora_data_api_client.py (lines 379-384, 688-693)

4. Lambda Deployment

  • Deployed updated data flattener Lambda to us-east-1
  • Successfully tested with 61 records from 8 files with 0 errors

Verified Results

Database Query Results (2025-10-21):

  • ✅ Citations JSONB: Full citation arrays with URLs and positions saved correctly
  • ✅ web_search_performed: Boolean flag tracking web searches
  • ✅ num_citations: Count of citations (e.g., 14 citations)
  • ✅ equal_experts_in_citations: Boolean tracking EE mentions in citations
  • ✅ citation_quality_score: DECIMAL(5,4) scores (e.g., 0.4250)

Citation Tracking View Results:

  • Perplexity/Sonar: 11 web searches today
  • 63.64% Equal Experts citation rate (7 out of 11 responses)
  • Average citation quality: 0.4250

Database Schema

New Columns:

  • citations JSONB - Full citation array from AI responses
  • web_search_performed BOOLEAN - Whether web search was used
  • web_search_timestamp TIMESTAMP WITH TIME ZONE - When search occurred
  • search_queries TEXT[] - Search queries used
  • num_sources INTEGER - Number of sources consulted
  • search_cost DECIMAL(10,6) - Cost of web search
  • equal_experts_in_citations BOOLEAN - Whether EE appears in citations
  • citation_quality_score DECIMAL(5,4) - Average citation relevance score
  • num_citations INTEGER - Count of citations in response

Analysis Views:

  • v_citation_analysis - Citation quality ratings and metrics
  • v_equal_experts_citation_tracking - EE citation rates by provider/model/date
  • v_citation_source_analysis - Top citation sources and domains

Migration Script

Created scripts/apply-citations-migration-simple.py for us-east-1 deployment.

All AI services (OpenAI, Claude, Gemini, Grok, Perplexity) are now successfully collecting and storing citation data!

happymonday2019 avatar Oct 21 '25 09:10 happymonday2019