开发工具 完美的 vim 缩进提示线插件

kikyous · 2013年03月04日 · 最后由 ginchenorlee 回复于 2013年03月29日 · 27776 次阅读

两个 vim 的缩进提示线插件

vim-indent-guides 这个是用高亮实现的 https://github.com/nathanaelkane/vim-indent-guides

高亮实现的缩进提示

indentLine 这个才是本文的重点 用 vim73 的 conceal feature 实现的 https://github.com/Yggdroot/indentLine 字符实现的

这个是我在 windows 上面的截图,效果很好

conceal

Vim 7.3 has some serious new features, one of which at least (:h persistent-undo) is a really, really big deal. But I’m not going to talk about those right this moment. Instead, I’m going to talk about something I just came across in a tweet and blog post by Perl hacker Yo-Ann Lin (aka c9s, aka cornelius).

The new feature is conceal, and it allows you to visually alter your code so that in place of a keyword lambda (or immediately before a lambda-like structure), you see λ. This is completely unnecessary (it doesn’t really do anything to your code), but it became absolutely essential to me. Having seen it for Perl and Python, I wondered how hard it would be to provide this for Ruby. It turns out not to be very hard at all.

if !has('conceal')
    finish
endif

syntax keyword rubyControl not conceal cchar=¬
syntax keyword rubyKeyword lambda conceal cchar=λ

set conceallevel=2

呃,冒昧说第一个实体线感觉更好。用了好多年还没自己写过 vim 的 function,惭愧。现在不想让 vim 挂太多插件。

#1 楼 @as181920 呵呵,各有所爱,我喜欢第二个,可能是更传统一些吧

第二个貌似有性能问题,文件大的话 vim 会变卡。

#3 楼 @yesmeck 手头没有太大的文件,试了一个 1284 行的 rb 文件,33.5k,没有遇到性能问题

#4 楼 @kikyous 好吧,我再用用看

Vim 真就那么好?! 不会用……

#6 楼 @Nori 那么多人都在用,总不会空穴来风吧

@Nori 这个怎么說呢?谁用谁知道😄,建议 vim 和 emacs 得修一个。

一直在找这样的插件啊

感觉两格缩进的话 第一个有点挤。。

第一个 Tab 会有问题,很宽

一直在用第一个。回来试试第二个。

#7 楼 @kikyous 恩,不知道多久能上手

#8 楼 @virgil 哦,sublime 都用不利索,还是先用好一个再说吧

一用上就爱上了!一直不爽原来高亮实现的缩进而坚持目测,现在终于有盼头了。 不过插件还有些问题,切换下文件就发现对齐线不见了……不知道是不是只有我有这个问题。等下个版本吧

#16 楼 @darkbaby123 这个插件的代码很少,不应该出现这样的情况,我觉得可能是插件冲突

@kikyous 昨天把问题提交给作者了,他也没碰到这个问题。今天整理干净了环境重新测试了下,还是有 bug……

.vimrc 已经尽可能精简了。MacVim 和 Vundle 都是必用的,如果还不行只好放弃了。

set nocompatible
filetype off

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

Bundle 'gmarik/vundle'

filetype plugin indent on
syntax on

set background=dark
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab

let g:indentLine_color_gui = '#A4E57E'

不错额,喜欢 debian

有没有 emacs 相关的啊?求大家推荐!!我一直想找个 emacs 这样的,但是没有找到过

#21 楼 @zealinux 哈哈,找的就是它,谢谢你的 推荐,好人一生平安 ~

需要 登录 后方可回复, 如果你还没有账号请 注册新账号