Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by

I've recently decided to split file name and display extension name separately with

set viewcolumns=-{fileroot}.,7{fileext},7{size}

Problem is that column takes the space in folder's section and cuts the long names leaving empty space. I assume You can't make a column show up only for files so how to make folder names to ignore that column and write over it?

1 Answer

0 votes
by

You can drop the dot after {fileroot} to allow its contents overflow into the next column.

Another option is to replace fileroot and fileext with a single custom column in Lua which aligns the two parts of the name accordingly.

by

You can drop the dot after {fileroot} to allow its contents overflow
into the next column.

Dropping dot works globally and I need it for filenames.

Another option is to replace fileroot and fileext with a single custom
column in Lua which aligns the two parts of the name accordingly.

Good to know that it's possible but I'm not smart enough to write my own scripts in any programming language.

Thank You anyway.

by

Not ideal (need at least text width function and might be a mess in tree-view), but you can try using this plugin:

--[[

    :set viewcolumns=-{RootAndExt},7{}

--]]

local function rootAndExt(info)
    local e = info.entry
    local offset = #e.classify.prefix

    local text

    if e.isdir then
        text = e.classify.prefix .. e.name .. e.classify.suffix
    else
        local root = vifm.fnamemodify(e.name, ':r');
        local ext = vifm.fnamemodify(e.name, ':e');

        if #ext ~= 0 then
            ext = '.' .. ext
        end

        root = e.classify.prefix .. root

        if #root + #ext >= info.width then
            text = root .. ext
        else
            local available = info.width - #root
            local extWidth = available > 7 and 7 or available
            if #ext > extWidth then
                extWidth = #ext
            end
            local rootWidth = info.width - extWidth

            local filler = string.rep(' ', rootWidth - #root)

            local format = string.format("%%s%%s%%%ds", extWidth)
            text = string.format(format, root, filler, ext);
        end
    end

    if not e.match then
        return { text = text }
    end

    return {
        text = text,
        matchstart = offset + e.matchstart,
        matchend = offset + e.matchend
    }
end

local added = vifm.addcolumntype {
    name = 'RootAndExt',
    handler = rootAndExt,
    isprimary = true
}
if not added then
    vifm.sb.error("Failed to add RootAndExt view column")
end

return {}

How to install.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.
...