继续 FSE 插件 - Jacky Liu's Blog

继续 FSE 插件

Jacky Liu posted @ 2011年7月15日 04:08 in Vim with tags plugin vim 插件 , 4422 阅读

---- 这是到目前为止写得最好,也是最有用的一个插件,各种爱不释手,现在用 Vim 时已经默认开在左边了。曾经看见有些小盆友在网上说什么“Vim 是个挺好的编辑器但是没法代替现代的 IDE”,各种鄙夷。我要是个程序员,一定按自己的喜好把 Vim 打造成最顺手的 IDE,用厂家的 IDE 只不过是在圈好的地里吃草而已。

---- 几个小改进:

1. 文件改名功能,也可以用来移动节点,用的是 Python 的 os.rename() 函数。

2. 新增一个自定义按键,在指定节点下打开文件浏览器 Nautilus

3. 批量删除功能,在 v 模式或 v line 模式下选中多个同级节点以后可以批量删除。

4. 智能定位按键在 v 模式和 v line 模式下也能用了,这样可以方便快速选中比较多的同级节点然后批量删除。

5. 浏览界面新增一个外观,节点前面添加了树形的分支符号,如图。因为字体的关系,符号之间有空隙,所以效果没有想像的那么好。总体上我觉得 Ubuntu 的 Courier 10 字体看着还是很顺眼的,只是没有十全十美。原来用 <Tab> 加不同颜色作缩进,是因为这样比较简单。这种方式现在还能用,靠选项可以切换。
 



---- 以后可能继续添加的功能:

1. 节点名过滤功能,通过自定义命令输入 py pattern,对节点名进行过滤。比如:
    “只显示 .py 文件”
    “不显示名称含有 'tmp' 的目录”
等等。

2. 标记功能,可以对经常访问的文件做标记,对应的高亮显示,快速跳转按键操作,等等。

3. 文件查找功能。与上面类似,通过自定义命令输入 py pattern 查找指定目录下的节点,结果在浏览界面里标识出来。

4. 改颜色 -- 收藏夹里的颜色难看到死,这我知道。FSE 是分两部分写的,中间隔比较久,写收藏夹那部分时,还不知道有这么多好看的 预定义颜色 可以用。有空再改改吧。

5. 在节点排序模式里添加 "bytype" 模式,按照类型来排序文件。这个比较麻烦,因为只靠扩展名来判断类型是不够的,比如图片文件和视频文件都有许多种扩展名,这个有时间慢慢弄。

6. 继续添加对文件类型的支持,能够调用合适的程序打开更多的文件类型

7. 添加对 soft link 和 mount 类型节点的支持。


---- 另外在改写插件的时候被一个非著名问题难住了:


在 Vim 里怎样得到当前光标所在列的列号?


写下这个问题时我就穿越了,人生真的就是循环往复。。。

这里说的列号不是 col('.'),那个是光标前的内容在内存里占多少字节,而我只是要知道光标前面有多少个字符而已。因为换用树形的符号作缩进以后,在相同位置上用 col('.') 或者 getpos('.') 得到的值与以前用 <Tab> 作缩进时不一样了,而如果不能正确判断列号的话,智能定位功能会有问题。我就纳闷,用 Vim 都 N 久了,怎么现在才遇到这个问题,而且一时还想不出办法来。

最后终于想出一个:

    collen= len(vim.eval(' col(".")==1 ? "" : getline(".")[:col(".")-2] ')) + 1

上面这是 Python 代码,因为 FSE 插件是用 Python 接口写的。如果是纯 VimScript 的话,就得这样:

    let collen= strlen( substitute( (col('.')==1 ? "" : getline('.')[:col('.')-2]) , '.', 'x', 'g') ) + 1

介个。。。拜托!谁有好点的办法没有?
 

------------------------------------------------------------------------- <补记> ---------------------------------------------------------------------------

---- 用 strchars() 函数好一点:

    let collen= strchars(col('.')==1 ? "" : getline('.')[:col('.')-2]) + 1

另外,用 strwidth()strdisplaywidth() 可以得到一个 string 在 Vim 里的显示宽度。

---- 对这几个函数怎么一点印象都没有 。。。

 

------------------------------------------------------------------------- <又补记> ---------------------------------------------------------------------------

---- virtcol() 函数,得到当前光标的显示位置(在第几个显示单元上)。功能不全一样,但也可用来判断光标位置与缩进等级之间的关系,感谢 依云 的回复。

 

Avatar_small
依云 说:
2011年7月16日 20:12

@Jacky Liu: 是 Vim 手册厉害。:help function-list ;-)

Avatar_small
BSEB Model Paper Cla 说:
2022年9月13日 18:16

Bihar State Vidyalay Pariksha Samiti, Patna Board (Bihar State School Examination Board) and others have designed and suggested the State Elementary Level Primary Education Class 3nd Grade study & learning material as Bihar Board 3rd Class Model Paper 2023 with Mock Test and Practice Questions. BSEB Model Paper Class 3 All Regional Students of Bihar Board can download the BSEB STD-3 Question Paper 2023 Pdf to All Languages and Subjects for SCERT & NCERT Syllabus students of Hindi Medium, English Medium and Urdu Medium Students Studding in Government & Private Schools of the State & Central Board.

Avatar_small
Emma 说:
2023年1月23日 19:55

FSE (Full-Screen Effects) plugin is a software tool that adds visual effects to full-screen applications and games. It can be used to enhance the appearance of games and other software that use a full-screen mode, by adding effects such as real estate agent Manson transparency, shadows, and blur. FSE plugins are typically compatible with a wide range of software and can be easily installed and configured.

Avatar_small
anonymous 说:
2023年8月12日 14:17

Find the best essays on     is my friend's profile page. Pest Control Kissimmee

Avatar_small
anonymous 说:
2023年8月21日 00:24

On this page, you'll see my profile, please read this information.  Pest Control Orlando

Avatar_small
anonymous 说:
2023年8月21日 00:30

You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog..preserve posting.. Pest Control Oviedo

Avatar_small
anonymous 说:
2023年9月15日 22:30

Your texts on this subject are correct, see how I wrote        this site is really very good. Mobile Home Supply

Avatar_small
anonymous 说:
2023年9月19日 19:51

Excellent read, Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. Comment se transformer intérieurement à Montreux Vevey Territet Chardonne Saint-Legier Villeneuve Chatel-Saint-Denis

Avatar_small
anonymous 说:
2023年9月22日 21:42

I have a similar interest this is my page    read everything carefully and let me know what you think. sunnewsonline

Avatar_small
anonymous 说:
2023年9月23日 19:09

Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing... schwarzkümmelöl

Avatar_small
anonymous 说:
2023年10月14日 02:04

Welcome to Therapy Trainings! We understand the economic challenges many new graduates face after completing their degree program.That's why we offer Free CEs, NAADAC Code of Ethics and Free CEUsfor Social Workers. As a new grad within the last six months, you'll receive unlimited CE access for a year, absolutely free!

Avatar_small
anonymous 说:
2023年10月19日 21:27

It's superior, however , check out material at the street address. Unimats

Avatar_small
anonymous 说:
2023年10月20日 21:09

Interestingly you write, I will address        you'll find exciting and interesting things on similar topics. Korean affordable skincare


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee