jiayi Rss

OpenSolaris vim 配置

Posted by jiayi | Posted in OpenSolaris | Posted on 29-09-2008

3

OpenSolarisvim 配了将近2个小时。比搭samp还难。。。

OpenSolaris 自带 vim 7,1,按说版本不低,但用上去相当崩溃,backspace 键行为古怪,只能撤销一次操作,语法高亮效果极次,等等等……今晚把openSUSE 11.0 里自己的 .vimrc 文件拽到 OpenSolaris 上,其他的问题都解决了,唯独彩色的语法高亮始终没有出现(当时所提供的语法高亮只是将关键字加粗,一些符号加下滑线)…不带高亮的 vim 用个P 哦…

Baidu 得知,在 .vimrc 中加上 term=sun-color,这样确实解决了问题,漂亮的语法高亮出现,但随后又有了新的问题:退出vim 后文本还停留在终端上,打开vim时终端的提示符会将文本覆盖,等等等…继续求索,google 英文得到正解,终端设成 term=xtermc。最初设成 xterm 没成功,xtermc 便搞定…恩,这时vim 和终端行为一切正常~

还有个小挠头的问题,退出时光标的位置不能被vim记录,下次打开文本光标又回到首行…
同样google解决…在 .vimrc 中加入

" Tell vim to remember certain things when we exit
"  ‘10 : marks will be remembered for up to 10 previously edited files
"  "100 : will save up to 100 lines for each register
"  :20 : up to 20 lines of command-line history will be remembered
"  % : saves and restores the buffer list
"  n… : where to save the viminfo files
set viminfo=’10,"100,:20,%,n~/.viminfo

" when we reload, tell vim to restore the cursor to the saved position
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
if expand("<afile>:p:h") !=? $TEMP |
if line("’"") > 1 && line("’"") <= line("$") |
let JumpCursorOnEdit_foo = line("’"") |
let b:doopenfold = 1 |
if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo – 1)) |
let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo – 1 |
let b:doopenfold = 2 |
endif |
exe JumpCursorOnEdit_foo |
endif |
endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
if exists("b:doopenfold") |
exe "normal zv" |
if(b:doopenfold > 1) |
exe "+".1 |
endif |
unlet b:doopenfold |
endif
augroup END

从用 openSUSE 10.1 以来,vim 配置月来越傻瓜,我也月来越傻瓜了……

总结起来,最关键的是在 .vimrc 中加上 term=xtermc,至于为什么,谁用 OpenSolaris 谁知道。。。



Vim远程编辑空间源代码

Posted by jiayi | Posted in shell, vim | Posted on 28-08-2008

4

各位bloger大都有web功底,而且改改网站代码也是日常之需。这里把jiayi平日使用本地vim远程编辑代码的方法记录下来。

工具:vim(越新越好~),expect,shell。

一般方法:
1.在/home/user目录创建expect文件edit.exp
加入如下代码

CODE

#!/usr/bin/expect
set timeout 100
set file [lindex $argv 0]
spawn vi ftp://192.168.1.1/domains/jiayii.com/public_html/$file #空间代码根目录
expect "username: "
send "your_uname\r" #空间用户名
expect "Password: "
send "your_pswd\r" #空间密码
interact

2.修改权限:

CODE


chmod
u+x edit.exp

3.修改目录
edit.exp拷贝到/sbin目录或其他

CODE

$PATH目录

4.使用
命令行执行 :

CODE

edit.exp index.php

人性化方法:
前两步相同

3.添加 alias
在.bashrc中加入: alias jiayivi=‘/home/user/edit.exp’

4.使用
命令行执行:

CODE

jiayivi index.php

好啦,现在就可以不受任何限制,尽情享受自己的vim了~~~