I'm often using grep to search for patterns and then opening the file with vim.

For example I've the following result in my shell:

interactions/BlockInteraction.js:38:                    .concat(this.prompt.postRender({}, '', renderer))
Container.js:151:        postRender : function(data, altClassName, renderer){
Container.js:156:                    return typeof elt.postRender === 'function';
Container.js:159:                    return elt.postRender(data, '', renderer);

What would enhance my productivity would be to be able to open a file with vim using the path:line pattern :

vim interactions/BlockInteraction.js:38 

Is there a way to do achieve that ?

  • 1
    You mean: instead of opening it with vim interactions/BlockInteraction.js +38 ? – Arjen Dijkstra Jul 14 '15 at 11:39
  • 1
    @Duikboot That doesn't generalize to opening multiple files. – Gilles 'SO- stop being evil' Jul 14 '15 at 13:28
  • grep, awk and something else for construct properly command line? Or looking/writing vim script for this task? – Alex Kroll Jul 14 '15 at 13:47

You can use the relatively popular file-line plugin. Note that this plugin seems relatively unmaintained, and there exists several forks. I have a personal fork where I've made some minor updates and fixed a couple of small bugs, see here.

| improve this answer | |
  • I've just checked the network on original plugin and it seems that it's once more active. Maybe you could pull your fixes into the main repo? – P4C Jan 17 '18 at 8:09
  • 1
    I'll consider it, thanks for notifying me. – Karl Yngve Lervåg Jan 17 '18 at 14:46
  • I think my fork has deviated too much, and I don't have the time to convert all of it to a well defined pull request. Thus instead I took the changes from bogado/file-line that seemed relevant and applied them to my fork. Works for me. – Karl Yngve Lervåg Jan 18 '18 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.