What's the meaning of some advanced patterns in vim errorformat? (%s, %+, %\\@=) -


i tried reading :help errorformat , googling (mostly stackoverflow), can't understand of patterns mentioned there:

  • %s - "specifies text search locate error line. [...]"
    • um, first of all, trying understand sentence @ all, put "text search", after %s? before it? or, don't know, maybe taint whole pattern? wtf?
    • secondly, pattern do, how differ regular text in pattern, kinda set efm+=,foobar? "foobar" here me "text search for"... :/
  • %+ - e.g. i've seen used in 1 question: %+c%.%#
    • does mean whole line appended %m used in earlier/later multiline pattern? if yes, if there not %.%# (== regexp .*), but, let's say, %+ccont.: %.%# - work capture stuff after cont.: string %m?
    • also, what's difference between %c%.%# , %+c%.%# , %+g?
    • also, what's difference between %a , %+a, or %e vs. %+e?
  • finally, example python in :help errorformat-multi-line ends following characters: %\\@=%m -- wtf %\\@= mean?

i'd grateful understanding stuff.

ah, errorformat, feature loves hate. :)

some meta first.

  • some vim commands (such :make , :cgetexpr) take output of compiler , parse quickfix list. errorformat string describes how parsing done. it's list of patterns, each pattern being sort of hybrid between regexp , scanf(3) format. of these patterns match single lines in compiler's output, others try match multiple lines (%e, %a, %c etc.), others keep various states (%d, %x), others change way parsing proceeds (%>), while yet others produce messages in qflist (%g), or ignore lines in input (%-g). not combinations make sense, , it's quite won't figure out details until @ vim' sources. shrug
  • you want write errorformats using let &erf='...' rather set erf=.... syntax much more human-friendly.
  • you can experiment errorformat using cgetexpr. cgetexpr expects list, interprets lines in compiler's output. result qflist (or syntax error).
  • qflists lists of errors, each error being vim "dictionary". see :help getqflist() (simplified) format.
  • errors can identify place in file, can simple messages (if essential data identifies place missing), , can valid or invalid (the invalid ones leftovers parsing).
  • you can display current qflist :echomsg string(getqflist()), or can see in nice window :copen (some important details not shown in window though). :cc take place of first error (assuming first error in qflist refers error in file).

now answer questions.

um, first of all, trying understand sentence @ all, put "text search", after %s? before it?

you don't. %s reads line compiler's output , translates pattern in qflist. that's does. see @ work, create file efm.vim content:

let &errorformat ='%f:%s:%m' cgetexpr ['efm.vim:" bar:baz'] echomsg string(getqflist()) copen cc  " bar baz " bar " foo bar 

then run :so%, , try understand what's going on. %f:%s:%m looks 3 fields: filename, %s thing, , message. input line efm.vim:" bar:baz, parsed filename efm.vim (that is, current file), pattern ^\v" bar\$, , message baz. when run :cc vim tries find line matching ^\v" bar\$, , sends there. that's next-to-last line in current file.

secondly, pattern do, how differ regular text in pattern, kinda set efm+=,foobar?

set efm+=foobar %m line in compiler's output starting foobar, assign rest of line message field in corresponding error.

%s reads line compiler's output , translates pattern field in corresponding error.

%+ - e.g. i've seen used in 1 question: %+c%.%# mean whole line appended %m used in earlier/later multiline pattern?

yes, appends content of line matched %+c message produced earlier (not later) multiline pattern (%a, %e, %w, or %i).

if yes, if there not %.%# (== regexp .*), but, let's say, %+ccont.: %.%# - work capture stuff after cont.: string %m?

no. %+ccont.: %.%# lines matching regexp ^cont\.: .*$ considered, lines not matching ignored. entire line appended previous %m, not part follows cont.:.

also, what's difference between %c%.%# , %+c%.%# , %+g?

%chead %m trail matches ^head .* trail$, appends middle part previous %m (it discards head , trail).

%+chead %m trail matches ^head .* trail$, appends entire line previous %m (including head , trail).

%+gfoo matches line starting foo , adds entire line message in qflist (that is, error has message field).

also, what's difference between %a , %+a, or %e vs. %+e?

%a , %e start multiline patterns. %+ seems mean "add entire line being parsed message, regardless of position of %m".

finally, example python in :help errorformat-multi-line ends following characters: %\\@=%m -- wtf %\\@= mean?

%\\@= translates regexp qualifier \@=, "matches preceding atom 0 width".


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -