1

First time poster, long time lurker, searched, couldn’t find etc, etc.

I’m running vim in tmux, in iTerm2. I’m running a server with Grunt.js, which I have running in the background, out of my way. I start my grunt server in the background like this:

grunt server &

Grunt also watches a bunch of files, and runs some tasks when any of the watched files have been written to. The problem is, when I am in vim and I write a file, the output from grunt starts rendering in vim! Here are some screenshots to illustrate the problem:

Before writing the file:

enter image description here

And after writing the file:

enter image description here

What have I tried?

I’ve tried running a ‘stock’ vim by starting with this:

vim -u NONE

…But the problem remains. This suggests to me that the problem is not with my .vimrc. Perhaps it’s an issue with iTerm2, I don’t know. Help.

  • Is the rogue text actually saved to the file and is still present when you reload it? – FreudianSlip Nov 7 '13 at 9:08
  • No, it’s cleared when vim redraws that region. I noticed this after disabling lazyredraw, and moving the cursorline over the artefacts. – Jezen Thomas Nov 7 '13 at 10:13
3

Starting a process as a background one does not automatically redirect its output. So what the background process sends to stdout or stderr appears in the terminal you started the process in.

Solutions

  • Redirect the output of the background process during start:
    grunt server >grunt-server.log 2>&1 &
  • Start the background process in a separate tmux session.
  • nohup automatically redirects the output to nohup.out:
    nohup grunt server &
  • if you do not need the output you can discard it:
    grunt server >/dev/null 2>&1 &
1

You can't fix that issue from Vim itself: grunt is just spitting stuff via stdout an that output is leaking in anything you do in that shell, Vim included. Normally, a simple <C-l> should cleanup the screen.

Either you find a way to silence grunt completely or you launch it in another iTerm pane/tab/window.

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.