vim中对调某特定字符两边的内容

如如下文本:
awerawedaew -> brthrtywertqwe aoyuilyilyi -> bsdfasfweghtyh asdfasdfasef -> basdfasdf
应用:
:%s/\(.*\) -> \(.*\)/\2 -> \1
结果:
brthrtywertqwe -> awerawedaew bsdfasfweghtyh -> aoyuilyilyi basdfasdf -> asdfasdfasef
\( \) :组 \1 :引用

Labels: , , ,

2009/04/26 10:46:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments

Archlinux中X-utils程序启动慢的终极解决方案

我先前发过一篇post,解决方案是把“/usr/share/X11/locale/zh_CN.UTF-8/XLC_LOCALE”中GBK全部注释,但是这个方案是治标不治本的,出现一些问题。

我放狗查了一下,貌似可以添加GBK字体的alias,不过在我这里无用(因为找不到update-fonts-alias这个东西。。。)。

刚才捣鼓了一下,把locale.gen中把en_US.*和zh_CN.UTF-8打开,然后运行命令:

sudo locale-gen

最后在.xinitrc中加入如下一行:

export LANG=zh_CN.UTF-8

最后就登录试一下运行X-utils程序,并没有出现卡的情况。。。

Labels: ,

2009/04/11 10:13:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments

Archlinux中X-utils程序启动慢的解决方案

Archlinux中如果设置locale为LC_ALL=zh_CN.utf-8的时候会出现X-utils启动很慢的情况,如xcalc、xclock、xterm等程序启动的时候很慢,但是启动成功之后正常。

原因是X-utils中的程序启动时候会查找“/usr/share/X11/locale/zh_CN.UTF-8/XLC_LOCALE”这个文件里面的GBK相关内容,使得启动非常慢,这时候只要把这个文件中的GBK那一段注释掉就行了,让你的X-utils启动如飞~


#  fs3 class (Chinese Han Character GBK)
#fs3 {
# charset {
# name GBK-0:GLGR
# }
# font {
# primary GBK-0:GLGR
# substitute GB13000.1993-1:GLGR
# }
#}
备注:实际上这个解决方案会出问题的,我的机器上具体体现是fvwm中的中文显示出现乱码,新的解决方案在此终极解决方案

Labels: ,

2009/04/08 7:52:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments

今日出现磁盘检测错误,后修复

今天在开机的时候出现了磁盘检测错误,提示信息如下:

/dev/sda3 contains a file system with errors, check forced. /dev/sda3: Inodes that were part of a corrupted orphan linked list found.

可能和这几天的频繁断电有关。经网上查询后顺利修复

先输入root密码,然后:

umount /dev/sda3 fsck.ext4 /dev/sda3

然后根据提示按y

Labels: ,

2009/03/15 10:35:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments

vi/vim鼠标中键粘贴不缩进的方法

vi/vim鼠标中键粘贴文本默认情况是自动缩进的,如果粘贴的是多行的文本,则第二行缩进1个tab,第三行缩进2个tab……依此类推,到最后文本会面目全非,解决办法是粘贴之前设置为粘贴(paste)模式。

:set paste

Labels: , , ,

2009/02/19 6:04:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 2 Comments

我的vi/vim编码设置

我在用vi打开中文txt文件时候经常会出现乱码的现象,在google之后加了“fileencodings”这个选项,能正常打开大部分文件了,但是还有少部分文件出现乱码;打开文件时候左下角的文件名显示总是乱码。

我的locale是zh_CN.UTF-8,对此我作了一些设定,最终达到了比较满意的效果:D。下面是.virc/.vimrc设置内容。

"vi与屏幕/键盘交互时使用的编码 set termencoding=utf-8 "UNIX方式的文件类型 set fileformats=unix "打开文件时用的编码 set fileencodings=ucs-bom,utf-8,GBK,big5,gb2312,cp936,gb18030 "vi的内部编码 set encoding=utf-8 "当前编辑的文件在存储时的编码 set fileencoding=utf-8 "对不明宽度字符的处理方式 set ambiwidth=double "取消文件自动备份 set nobackup "不使用鼠标功能 set mouse=""

Labels: , , ,

2009/02/15 10:33:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments

Archlinux下无法mount 镜像的问题

新的内核默认不启动loop,所以mount iso之前要执行:
sudo modprobe loop
然后才mount -o loop *.iso /mnt/iso

Labels: ,

2008/11/16 5:21:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 3 Comments

login后直接startx

如果没装GDM、KDM、XDM等登录管理器,又想在login后直接startx,可以在~/.bashrc末尾添加如下代码:
if [ ! -e /tmp/.X*-lock ]; then startx fi

Labels: ,

2008/11/11 4:43:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments

vim设置

set termencoding=utf-8
set encoding=prc
set fileformats=unix
set encoding=prc
set fileencodings=utf-8,gbk,ucs-bom,cp936,gb2312 #中文编码设置
set mouse-=a #禁止鼠标选中就进入可视模式
set nobackup #取消备份文件(~file)

Labels: ,

2008/11/06 5:09:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments

linux下的firefox支付宝插件可以使用了~

终于不用再开ies4linux来上支付宝了... 来自:http://blog.alipay.com/301.html

自从上次支付宝在官方网志上宣布将支持 Firefox 浏览器后,已经有很多用户询问什么时候能够支持 Linux 平台下的 Firefox ,现在是可以做出回答的时候了:尽管该安全控件(针对 Linux 下 Firefox 的安全控件)还没有正式在官方网站上发布,本 Blog 用户可以提前体验啦。

使用方法:下载上述链接的文件,解压缩成两个文件:

$ tar -zxvf aliedit.tar.gz 

推荐校验 MD5 值:

$ md5sum aliedit.tar.gz
02240053d32688ed996e3a4788042801  aliedit.tar.gz

并将这两个文件复制到 ~/.mozilla/plugins 目录:

$ cp aliedit.so aliedit.xpt ~/.mozilla/plugins 

重新启动 Firefox 即可。

安全提示:下载前请做一下 MD5 校验。同时在官方站点发布正式的针对 Linux 下 Firefox 的安全控件之前,不要相信任何来自其他网站的安全控件。

补充说明:目前在 Linux 下的支付宝安全控件也不支持数字证书。

Labels: ,

2008/10/23 5:32:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 1 Comments

Way to wine tygem.wine弈城/TOM对弈/Tygem的方法

While I use tygem to play GO,it runs slow and I think noone can stand it. so how to make it faster? First,copy the follow dll files from you windows xp's directory C:\windows\system32\ to ~/.wine/drive_c/windows/system32/
cryptui.dll mciole32.dll msvcp60.dll oleaut32.dll riched20.dll shdocvw.dll mfc42.dll
Then,open the wine config tool winecfg add program LiveBaduk.exe to it,select it and then change to the label to "Libraries" and add the dll files above.Then click OK. 先在一个windows xp 下的system32 中找到
cryptui.dll mciole32.dll msvcp60.dll oleaut32.dll riched20.dll shdocvw.dll mfc42.dll ole32.dll riched32.dll shlwapi.dll
这几个dll,弄到~/.wine/drive_c/windows/system32/下面 然后在虚拟终端下输入 winecfg进入wine设置,在添加程序那里找到并添加弈城的主程序LiveBaduk.exe,再选中LiveBaduk.exe,点函数库标签, 把上面那些dll加入进去就搞定了,这样子就不会在下棋时候卡了,如果还是速度慢的话就不是dll的问题了.一般解决问题如下: 参照:
Ubuntu下wine运行慢的解决方法 修改XLC_LOCALE , 让她不要请求这些多余字体 修改 /usr/share/X11/locale/zh_CN.UTF-8/XLC_LOCALE 把里面有 GBK 字样的段全部删掉,或者干脆把 GB2312 和 GB13000 的也全部删掉。 这样, wine 在 zh_CN.UTF-8 下的速度就跟 en_US 下一样快了, 而 XIM 输入法这些也没影响。

Labels: , , ,

2008/10/17 11:11:00 AM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments

用Icecast+Ezstream架设网络广播平台

一直想在Linux下面搞网络广播,现在终于可以搞出来了,因为拥护开源的原因,我选择了 Icecast+Ezstream,这个是占用资源非常小的组合。 软件:Icecast+Ezstream Icecast可以用apt-get install或者yum之类的直接下载安裝,或者可以编译安裝。Ezstream就只有自己从网站上下载编译了,按照README的提示./configure,然后sudo make ,sudo make install. 安裝完成之后就是配置了。 首先,把自己加入icecast用户组:
$ vim /etc/group 把自己的用户名加入icecast组,如:icecast:x:121:lao,root
然后更改日志权限
$ sudo chmod 775 /var/log/icecast2
把配置文件单独弄出来方便编辑:
$ cd ~ $ mkdir .broadcast $ cp /etc/icecast2/icecast.xml /usr/local/share/examples/ezstream/ezstream_mp3.xml ~/.broadcast/
这里用ezstream_mp3.xml 这个简单的例子就够了 Icecast必要配置:
最大允许的电台数: <limits> <sources>5</sources> </limits> 改掉这里的密码: <source-password>hackme</source-password> 端口设置: <listen-socket> <port>8000</port> <!--这是用户连接所用的端口,每开一个电台需要指定一个端口--> <!-- <bind-address>127.0.0.1</bind-address> --> <!--如果你的电脑有多个ip,可以在这里绑定一个,不绑定就应该是可以使用所有可用ip--> </listen-socket>
Ezstream配置:
编辑ezstream_mp3.xml即可,密码,端口设置和Icecast一样: ...... <url>http://192.168.1.50:3333/mp3</url> <!--这里设置url,以后就是用这个地址来收听,记得保留'mp3'这样的挂载点--> ...... <filename>playlist.m3u</filename> <!-- 播放列表,可以通过“find /your-mp3s'-dir/ -type f -name "*.mp3" > ~/.broadcast/playlist.m3u”命令来生成-->
到这步已经可以启动广播了,
$ icecast2 -c ~/.broadcast./icecast.xml & $ ezstream -c ~/.broadcast./ezstream_mp3.xml &
有趣的是,可以通过运行多个Ezstream启动多个广播,比如复制几个Ezstream的配置文件,把挂载点“mp3”换成其他的(“music...”),然后
$ ezstream -c ~/.broadcast./*.xml &
现在你已经在开广播啦~ 如果你嫌每次启动这两个程序麻烦,可以写一个类似这样的脚本:
#!/bin/bash cd ~/.broadcast case $1 in "start") icecast2 -c ./icecast.xml & ezstream -c ./ezstream_mp3.xml & ;; "stop") killall -e -w icecast2 ezstream echo "电台程序已经关闭" ;; esac
另存为一个合适的名字(bcast?) ,然后
$ sudo mv bcast /usr/local/bin/ $ sudo chmod a+x /usr/local/bin/bcast
这样每次想启动就用
$ bcast start
关闭就用
$ bcast stop
好了,就写到这里了,上面肯定有一些错误,欢迎大家指正,或者有一个更好的脚本提供也可以。

Labels: ,

2008/03/20 9:32:00 PM  By Lao | License:by-nd/3.0 | 繁體  English | 0 Comments