The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Ancient UNIX systems, screen, and vi

PowerpuppiesPowerpuppies drinking coffee in themountain cabinRegistered User regular
edited April 2011 in Help / Advice Forum
I work at a place where I can't install anything onto my workstation or download anything from the internet onto it. Right now I have to do a significant portion of my work through a very clogged high-latency link. It can take minutes to open a graphical window, so I do whatever editing I'm forced to do through the link in vi. One problem I've been having is if there are 7 compiler errors caused by typos and simple things, I can't fix them all without recompiling. I vi the file and fix one or two errors, and then when I come back the error messages are obliterated by the residual text from vi.

A coworker suggested screen yesterday, which repaints the compiler errors when I exit vi. It also handles terminal resizing properly, which is quite nice.

Problem is, if I run vi through screen on the other side of this link, any mistake I make leads to a 'visual bell'-my whole screen flashes white. It's not unusual for me to press delete and hold, if I want to delete everything on the line but not the line itself. Or hold the left arrow key, etc. Because of the latency of the link, it's hard to judge when to let go, because my screen is 2 seconds behind the keyboard commands. If I hit left arrow or delete when at the start of the line, I get the vbell. If I was holding left arrow or delete and didn't let go fast enough, my screen lights up the room like it's determined to give me an epileptic fit.

I turned off visual bells in screen, and I used the noerrorbells option in vi, but I still get visual bells not related to errors, I guess? The triggers above still flash the screen. These versions of vi don't accept set _vb or set t_vb commands, so any solution involving those doesn't work. Turning off visual bells on the X server didn't work, and xterm doesn't seem to have an option for removing visual bells. The bells don't happen except when I'm using screen... is there any way I can take away vi's ability to visual bell that I haven't tried here?

tl;dr: Screen lets an old version of vi use visual bells when raw xterm or gnome terminal doesn't. Screen is really helpful for other reasons, but these bells are a dealbreaker. Any way to stop vi from being able to use virtual bells?

sig.gif
Powerpuppies on

Posts

  • aperlscriptaperlscript Registered User regular
    edited March 2011
    One problem I've been having is if there are 7 compiler errors caused by typos and simple things, I can't fix them all without recompiling. I vi the file and fix one or two errors, and then when I come back the error messages are obliterated by the residual text from vi.

    Have you tried playing with your $TERM variable? I've seen different behavior depending on if I'm using "xterm" or "xterm-color". Both will allow color, but they differ in the way then handle screen-clearing and other minor operations. I'm going from Terminal.app (OSX) to Debian, so YMMV.

    I don't know enough about the guts of term to offer anything else, sorry.

    aperlscript on
  • usul512usul512 Registered User regular
    edited April 2011
    It's been a while and I mostly used vim, not straight up vi, but...

    :set errorbells/noerrorbells indeed only applies to errors so other things will still set off the visual bell as you've already noticed

    Try the following:

    :set noerrorbells
    :set visualbell
    :set vb t_vb=

    If that doesn't work, stop making mistakes :-P

    Instead of mashing keys, get good at the keyboard shortcuts, "0" followed by "d$" will clear a line without removing it (move to start of line, delete to the end. If you're at the end of the line you can do "d0x" to delete the line and the last character which will be left over).

    Good luck!

    usul512 on
  • soxboxsoxbox Registered User regular
    edited April 2011
    Learning more about screen will also no doubt help you if you're not that up on it. http://www.gnu.org/software/screen/

    Most usefully: starting it using screen -DD -R will resume your last session. CTRL-a+c to create new screens and CTRL-a+n to cycle through them.

    soxbox on
  • theSquidtheSquid Sydney, AustraliaRegistered User regular
    edited April 2011
    Why not have your compiler output into a file as well as the console when it runs? The 'tee' command covers this.

    so
    compiler_command | tee nameoffile.txt
    

    will output both to the console and the file nameoffile.txt at the same time. The -a option will append.

    Then you can just 'cat nameoffile.txt' when you need it.

    theSquid on
  • PowerpuppiesPowerpuppies drinking coffee in the mountain cabinRegistered User regular
    edited April 2011

    Have you tried playing with your $TERM variable? I've seen different behavior depending on if I'm using "xterm" or "xterm-color". Both will allow color, but they differ in the way then handle screen-clearing and other minor operations. I'm going from Terminal.app (OSX) to Debian, so YMMV.

    I don't know enough about the guts of term to offer anything else, sorry.

    Thanks, I didn't know about this.
    usul512 wrote: »
    It's been a while and I mostly used vim
    probably because you don't have the worst dev environment in the known universe:lol:

    Try the following:

    :set noerrorbells
    :set visualbell
    :set vb t_vb=

    If that doesn't work, stop making mistakes :-P
    soxbox wrote: »
    Learning more about screen will also no doubt help you if you're not that up on it. http://www.gnu.org/software/screen/

    Most usefully: starting it using screen -DD -R will resume your last session. CTRL-a+c to create new screens and CTRL-a+n to cycle through them.

    None of the above works, and I've already stopped using screen, since the bells bug me way more than doing without screen.
    theSquid wrote: »
    Why not have your compiler output into a file as well as the console when it runs? The 'tee' command covers this.

    so
    compiler_command | tee nameoffile.txt
    

    will output both to the console and the file nameoffile.txt at the same time. The -a option will append.

    Then you can just 'cat nameoffile.txt' when you need it.

    this is obvious and I feel like a moron for not having thought of it! Thanks. I'm going to edit my alias to include this. Will tee overwrite the existing file, or do I need to prepend an 'rm' command to the alias?

    Powerpuppies on
    sig.gif
  • PowerpuppiesPowerpuppies drinking coffee in the mountain cabinRegistered User regular
    edited April 2011
    Oh yeah and this can be locked

    Powerpuppies on
    sig.gif
Sign In or Register to comment.