te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>netrw - How to mimic Lexplore behavior in Vim 7.4 - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

netrw - How to mimic Lexplore behavior in Vim 7.4 - Stack Overflow

programmeradmin4浏览0评论

This topic in SE has confirmed that I cannot use Lexplore in Vim 7.4 (which is what I'm currently using). I cannot download plug-ins as my workstation is in a secure environment, and unless I request our IT to upgrade Vim (which is very difficult), I'm stuck with finding workarounds to mimic Lexplore.

Any help on how I can mimic Lexplore in Vim is much appreciated. Thank you in advance!

This topic in SE has confirmed that I cannot use Lexplore in Vim 7.4 (which is what I'm currently using). I cannot download plug-ins as my workstation is in a secure environment, and unless I request our IT to upgrade Vim (which is very difficult), I'm stuck with finding workarounds to mimic Lexplore.

Any help on how I can mimic Lexplore in Vim is much appreciated. Thank you in advance!

Share Improve this question asked Feb 18 at 3:38 renvillrenvill 1631 silver badge11 bronze badges 1
  • 1 Note that Vim 7.4 was released in 2013 and superseded by Vim 8 in 2016. One hell of a secure environment to work in. – Friedrich Commented 2 days ago
Add a comment  | 

1 Answer 1

Reset to default 1

How faithful do you want your :Lexplore emulation to be?

A superficial "open a slim vertical Netrw window on the left side of the current window" is as simple as:

:20Vexplore!

But you may want that slim window to take the full height of the screen. Moving the window to the far left side of the screen is easy enough with an additional :help :wincmd:

:20Vexplore!|wincmd H

Note that 20 is a percentage, here, not a number of columns.

But, here, the width of the window is lost in the process. In my quick tests, neither :set noequalalways nor :set winfixwidth appear to have any effect on that, which is surprising, honestly. But you can still use :help vertical-resize and a bit of calculation:

:Vexplore!|wincmd H|execute 'vertical resize ' .. &columns / 100 * 20

Let's turn that into a custom mapping:

function! LexploreOpen()
    Vexplore
    wincmd H
    execute 'vertical resize ' .. &columns / 100 * 20
endfunction
nnoremap <F5> :<C-u>call LexploreOpen()<CR>

Now you can press <F5> to open your :lexplore lookalike.

But what really sets :Lexplore apart from :help Vexplore is that it is a toggle: you do :Lex to open it and :Lex again to close it.

You can use a global variable for that:

function! LexploreToggle()
    if exists('g:FakeLexploreIsOpened')
        wincmd t
        close
        unlet g:FakeLexploreIsOpened
    else
        Vexplore
        wincmd H
        execute 'vertical resize ' .. &columns / 100 * 20
        let g:FakeLexploreIsOpened = 1
    endif
endfunction
nnoremap <F5> :<C-u>call LexploreToggle()<CR>

Setting a window-local option and closing the window that has it set would be cleaner, IMO, but I don't remember what functions were available back then for that. See if :help getwinvar() can help.

Anyway, this should give you a reasonable approximation of :Lexplore but it accepts a path, for starter, and the snippet above doesn't. And it is entirely possible that the original command does other things, like setting various useful internal Netrw variables and so on. This means that the closer you want to get from the real :Lexplore, the more involved it will be. For a full clone of :Lexplore I'm afraid you will have to look at Netrw's code.

Note that there is no fundamental difference between the snippet above and a "plugin" so, if you can get that snippet into your secure environment, then you can also probably get a recent Netrw.

发布评论

评论列表(0)

  1. 暂无评论