Skip to content

Instantly share code, notes, and snippets.

@goose121
goose121 / vi_column_fix.md
Last active October 15, 2020 18:00
vi terminal too wide fix

The vi command in some configurations (e.g. Solaris) will give the error "Terminal too wide" if launched on a terminal with more than a certain number of columns. One way to fix this is to modify the source code, as detailed in this Arch Linux bug report. If the source code is unavailable or the limit otherwise cannot be modified, a work-around is the following script, to be put in one's .profile.

VI_COLS=163

vi () {
    local original_cols=$(tput cols)
    if [ "$original_cols" -gt "$VI_COLS" ]; then
        stty columns "$VI_COLS"
        "$(which vi)" "$@"