micro-editor / micro-editor/micro

Implement a more user-friendly "literal replace" functionality

Open
#2,963 4 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
29.6k
Forks
1.4k
Avg merge
2d 18h
Merged PRs (30d)
10

Description

Description of the problem or steps to reproduce

This is a feature request which naturally grows out of some reported issues/bugs related to the "replace" functionality. See:
#2951 #2937 #2887 #2832 #2174 #2155 #1920
(I'm not sure if some of the older issues have been partially or fully resolved by now but the issues are still technically open)

Basically the request is to implement:

  1. A way to have literal replace that is actually literal, a.k.a not interpreting absolutely anything, including spaces, backslashes, quotation marks, "$" and other special symbols. You just enter whatever arbitrary string you want to replace, enter another arbitrary string to replace with, and get it done.
  2. Probably implement a better UI for that which should feature separate fields for "string-to-replace" and "replacement-string" (see the rationale in my comment in the discussion inside #2951).
  3. [if not too much work ] As a part of that UI, implement a simple switch for regex or literal mode (maybe toggle by pressing a specific key)
  4. As a part of that UI, implement a button for "replace all" (maybe activate by pressing a specific key)
  5. [ if not too much work ] implement a switch to toggle case-sensitive (or not) search/replace
  6. Consider setting literal replace as the default since (my personal opinion) literal replace is used much more frequently by most users.
  7. Possibly combine the replace UI with the "Find" UI so it's easy to do a task like find all instances of a string in a file, [possibly tweak the string to match exactly what you need to], switch to "replace" mode and replace all instances in one go, without having to re-enter the string again (would be a nice perk but not life-changing). See for example Notepad++ implementation (although that's GUI of course but I don't see why something equivalent, while limited to the above-mentioned features, can't be implemented in a text-based UI, at least the way it's done in Nano for example).

(1) which, as I think, requires (2), is the essential part, at least for me, although each of the other parts will definitely help if possible to implement.

Commit hash: c2cebaa
OS: Debian
Terminal: xterm

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing replace and Find interfaces, then read the related discussions in issues #2951, #2937, #2887, #2832, #2174, #2155, and #1920. Define the smallest scope around truly literal replacement and separate search and replacement inputs before considering the optional mode, case-sensitivity, replace-all, and combined Find UI requests. Done should include working literal replacement for arbitrary strings and a clear way to verify the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.