micro icon indicating copy to clipboard operation
micro copied to clipboard

Support +/$text command line argument

Open luca020400 opened this issue 7 months ago • 9 comments

This is a feature found in vim and for example used by Linux kernel test robots to give context about warnings and/or failures.

e.g. vim +/imem_size +623 drivers/net/ipa/ipa_mem.c

Means to search for imem_size and move cursor to line 623.

The behavior found in VIM is as follows:

  • If line:col is specified before the search starts from that position and if a match is found the cursor jumps to the match (also wrapping around the buffer).
  • If the search if specified before and a match is found it highlights the search field and then moves the cursor as specified in line:col.

As for multi-file handling it applies the last rule in command line takes over.

Not sure if that's something you'd be interesting to support but it's quite handy.

There's a crude implementation here https://github.com/luca020400/micro/commit/894043ae3f9704d2d6bb91c082be618f385ddb58 that implements it in an hacky way via .Search (couldn't find a proper API for now)

Ty.

luca020400 avatar May 23 '25 20:05 luca020400

https://github.com/luca020400/micro/commit/fd0365bd67175a5b5b49203d75f593f17e19b505 Implements a very similar behavior to what I see on VIM that also take into account the order of commands passed via cmdline, shall I open a PR directly?

luca020400 avatar May 26 '25 20:05 luca020400

I like that it implements Plus backslash search functionality and the vim aspect is pretty cool too. I commented on another avenue for executing the search functionality using a buff pane which may help.

And maybe prudent to observe that if plus backslash search is called without a line column command line argument then the search fails.

Vim handles differently than the branch cited iow fwiw

cargilcm avatar May 28 '25 21:05 cargilcm

Ah yea I completely forgot about +/text only usecase, my bad, will fix tomorrow

luca020400 avatar May 28 '25 21:05 luca020400

luca020400@fd0365b Implements a very similar behavior to what I see on VIM that also take into account the order of commands passed via cmdline, shall I open a PR directly?

IMO this would be a nice feature, so why not.

dmaluka avatar Jun 01 '25 12:06 dmaluka

https://github.com/zyedidia/micro/pull/3767 Opened a PR

luca020400 avatar Jun 01 '25 19:06 luca020400

No offense looks nice but the +/text only use case?

cargilcm avatar Jun 01 '25 20:06 cargilcm

No offense looks nice but the +/text only use case?

works just fine, I just missed adding None in the switch case

luca020400 avatar Jun 01 '25 20:06 luca020400

No offense looks nice but the +/text only use case?

works just fine, I just missed adding None in the switch case

Sorry, I don't know why it's not working for me (I don't think), as I get different results than vim. For instance, +/text only works for me if the command arg +/line precedes it. Any guesses why it could differ?

Here's my command verbatim ./micro +/Goto internal/action/command.go

I noticed the pull request code was updated last week. Did you incorporate the additional switch in this (commit that none into the pr branch)?

cargilcm avatar Jun 01 '25 21:06 cargilcm

No offense looks nice but the +/text only use case?

works just fine, I just missed adding None in the switch case

Sorry, I don't know why it's not working for me (I don't think), as I get different results than vim. For instance, +/text only works for me if the command arg +/line precedes it. Any guesses why it could differ?

Here's my command verbatim ./micro +/Goto internal/action/command.go

Works just fine here... it jumps to line 44 Same as ./micro internal/action/command.go +/Goto

The arg matching logic doesn't care about the order of files and +/$text at all

I noticed the pull request code was updated last week. Did you incorporate the additional switch in this (commit that none into the pr branch)?

The PR has the None switch patch included

luca020400 avatar Jun 01 '25 21:06 luca020400