andreikop / enki

A text editor for programmers
http://enki-editor.org
GNU General Public License v2.0
161 stars 38 forks source link

Range replace does not work (or is unintuitive) #118

Closed vi closed 11 years ago

vi commented 11 years ago

I do the following:

  1. Select the several lines in Enki;
  2. Press Ctrl+R;
  3. Type "^" into "Search" field; (Enki jumps to the first line...)
  4. Press Tab (go to Replace field);
  5. Type "//";
  6. Press Enter.

Expected: like '<,'>s!^!//! in Vim

Actual: the first line gains "//".

andreikop commented 11 years ago
  1. It might be not intuitive, but Enki searches regexps in the whole text, not in every line, therefore ^ is start of file, not line. To add // to the start of lines, replace \n with \n// This behavior is necessary to allow to search/replace multiline patterns.
  2. Enki doesn't honor selection, when replacing text. Whole text or matches one by one are replaced.
  3. (Un)commenting code lines is very common action. Enki should do it on shortcut. Open an issue about it.
vi commented 11 years ago

How to do range replace in Enki?

Even with special command for [un]commenting blocks (in all languages? really?) substitude with a range can be useful.

Can be in form of

  1. Select some text;
  2. "Open selected text as a separate buffer";
  3. Apply global search&replace in the mapped buffer.

Also maybe incremental search highlighting should start searching for matches from the current cursor position (wrapping around EOF up until current position), not from the beginning? That way regex with high number of matches will be closer to current position...

andreikop commented 11 years ago

When search or replace shortcut is used, selection is copied to search input. If selection is also used for range replace, behavior will be to o complicated 08.09.2013 13:57 пользователь "Vitaly Shukela" notifications@github.com написал:

How to do range replace in Enki?

Even with special command for [un]commenting blocks (in all languages? really?) substitude with a range can be useful.

Can be in form of

  1. Select some text;
  2. "Open selected text as a separate buffer";
  3. Apply global search&replace in the mapped buffer.

— Reply to this email directly or view it on GitHubhttps://github.com/hlamer/enki/issues/118#issuecomment-24018827 .