Justifying/aligning errorformat output in Vim -


i use vim/gvim programming in javascript (node). have jslint wired makeprg in filetype plugin. here's errorformat:

efm=%-p%f,         \%a%>%\\s%\\?#%*\\d\ %m,%z%.%#line\ %l\\,\ pos\ %c,         \%-g%f\ is\ ok.,%-q 

and here output of jslint:

routes/pcr.js #1 'db' used before defined. db.collection('pcrs', function (err, collection) { // line 11, pos 5 #2 'db' used before defined. db.collection('pcrs', function (err, collection) { // line 23, pos 5 #3 'bson' used before defined. collection.findone({'_id': new bson.objectid(id)}, function (err, item) { // line 24, pos 40 

and here output quickfix window:

routes/pcr.js|11 col 5| 'db' used before defined. routes/pcr.js|23 col 5| 'db' used before defined. routes/pcr.js|24 col 40| 'bson' used before defined. 

after column number, i'd left pad out 2 digits (i hope file has no more 99 errors!) looks like:

routes/pcr.js|11 col  5| 'db' used before defined. routes/pcr.js|23 col  5| 'db' used before defined. routes/pcr.js|24 col 40| 'bson' used before defined. 

i guess affect line numbers 0-9 well. possible conditionally pad output?

:help quickfix-window mentions reformatting of error lists.

the following setting works me(update):

au bufread quickfix setl modifiable             \| silent exe "%!perl -ple '                 \my ($file, $pos, $msg) = split qr{[|]}, $_, 3;                 \my $aligned_pos = sub {                 \  @p = split qr{[ ]}, shift;                 \  return                                        if @p == 0;                 \  return sprintf q{\\%3s}, @p                   if @p == 1;                 \  return sprintf q{\\%3s \\%s}, @p              if @p == 2;                 \  return sprintf q{\\%3s \\%s \\%2s}, @p        if @p == 3;                 \  return sprintf q{\\%3s \\%s \\%2s \\%-8s}, @p if @p == 4;                 \  return join q{ }, @p;                 \}->($pos);                 \$_ = join q{|}, $file, $aligned_pos, $msg;             \'"             \| setl nomodifiable 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -