vim

请下载 janusarrow-up-right 节省不必要的配置时间

自定义的配置放在~/.vimrc.after里面

以下的很多操作默认使用janus安装的插件

例如快速跳转\w \b,注释\cc,格式化等等

tab

python可能4个空格缩进,ruby或者别的一些规定2个空格
下面是关于空格我的~/.vimrc.after,默认tab是4个空格(pythoner),如果写coffee的
话默认两个

set tabstop=4       " A four-space tab indent width is the prefered coding style
                " for Python (and everything else!), although of course some
                " disagree. This page generally assumes you want 4-space
                " indents.

set shiftwidth=4    " This allows you to use the < and > keys from VIM's visual
                    " (marking) mode to block indent/unindent regions

set smarttab        " Use the "shiftwidth" setting for inserting <TAB>s instead
                    " of the "tabstop" setting, when at the beginning of a
                    " line. This may be redundant for most people, but some
                    " poeple like to keep their tabstop=8 for compatability
                    " when loading files, but setting shiftwidth=4 for nicer
                    " coding style.

set expandtab       " expandtab    et    Insert spaces instead of <TAB>
                    " character when the <TAB> key is pressed. This is also
                    " the prefered method of Python coding, since Python is
                    " especially sensitive to problems with indenting which can
                    " occur when people load files in different editors with
                    " different tab settings, and also cutting and pasting
                    " between applications (ie email/news for example) can
                    " result in problems. It is safer and more portable to
                    " use spaces for indenting.

set softtabstop=4   " softtabstop=4    sts    People like using real tab
                    " character instead of spaces because it makes it easier
                    " when pressing BACKSPACE or DELETE, since if the indent
                    " is using spaces it will take 4 keystrokes to delete
                    " the indent. Using this setting, however, makes VIM see
                    " multiple space characters as tabstops, and so <BS> does
                    " the right thing and will delete four spaces (assuming
                    " 4 is your setting).

set autoindent      " autoindent    ai    Very painful to live without this
                    " (especially with Python)! It means that when you press
                    " RETURN and a new line is created, the indent of the new
                    " line will match that of the previous line.

autocmd FileType coffee setlocal tabstop=2 shiftwidth=2 softtabstop=2

可视化

行级别 shift + v 列级别 ctrl + v

可视化是很重要的一个部分,还记得你在记事本里面用鼠标选中某些文字, 然后复制粘贴么?在vim里面只要ctrl + v 然后拉动 h l 等选中文字,y可以复制选中的文字,x可以删除选中的文字,大写I进行插入 按Esc之后会有惊喜(多行注释常用)

打开tab,来回切换

:tabedit path

切换ctrl + pageup/pagedown

tab映射,让你的vim变的更加方便

有了tab功能,并且可以方便的切换,vim的易用性显得更高了。

http://www.douban.com/group/topic/23129658/arrow-up-right

打开tab list

迅速找到并打开当前vim文件夹下的文件

例如: 文件目录如下,你正在编辑 /home/duoduo/proj/A.txt:

迅速打开# 路径的文件

滚屏

查找移动光标

在行上添加或者减少缩进

一些之前少用的编辑小命令

移动当前行

合并两行

快速跳转单词

\w 向后跳转 \b 向前跳转

例如vim 编辑a文章,然后你用ctrl+p跳到了别的地方,跳回a的方法

记录位置,迅速跳转

s指任意字母 S是大写,例如ma 用a记录下一个位置,然后光标随意移动, 'a即可跳回。大写的话即使你在别的tab下也可以很方便的跳回这个位置。

记录 m{Ss} 跳回 '{Ss}

另外 当使用G跳转的时候,跳转点会自动mark,''即可跳回

注释

添加\cc 取消\cu

经常与shift+v 可视块一起使用

粘贴模式

按F4进入粘贴模式,这样要粘贴的文字的格式就会被保留下来。

注意复制粘贴的时候需要先进入insert模式

打开文件时(:tabedit 或者ls等)查看目录下文件

ctrl + d

snippets

https://github.com/honza/vim-snippets/tree/master/snippetsarrow-up-right

常用的片段

html常用

https://github.com/honza/vim-snippets/blob/master/snippets/html.snippetsarrow-up-right

Elements

都可以直接元素类型加. #

input:hidden 等可以直接指定type

jquery

https://github.com/honza/vim-snippets/blob/master/snippets/javascript-jquery.snippetsarrow-up-right

一般直接写方法名

python

https://github.com/honza/vim-snippets/blob/master/snippets/python.snippetsarrow-up-right

添加自己的issue

在janus里面这个插件在~/.vim/janus/vim/tools/vim-snippets/snippets下

例如:当写zarkpy继承model的时候就可以新建以下的模板,在.py文件中输入clm按下tab就会补全

log print 调试

单词大小写转化

vim 编译coffeescript

~/.vimrc.after

替换

vim正则需要括号括起来并且加斜杠转义, &代表匹配到的东西

为每行后面添加,号'<,'>s/.*/&,/g

将 abc变为 self.abc = abc '<,'>s/\(\w\+\)/self.& = &/g

recording模式

当你有重复的一些操作需要执行的时候就用recording,或者说是宏

q + 任一a~z 例如 q a, 然后你做一些操作,完成后按q, 那么命令都录制在a这里

使用时 @a即可,如果想重复100次,100@a

ctags快速跳转到函数定义

~/.vimrc.after里面添加

然后到项目根目录下执行ctags -R

需要调整到方法定义时在方法或者类名上ctrl+],跳回ctrl+o

Last updated

Was this helpful?