存档

‘Tools & Tips’ 分类的存档

My Vimrc File

2009年12月24日 Killman 没有评论

Apply the recommend vimrc file:

cp /usr/share/vim/vimcurrent/vimrc_example.vim  /usr/share/vim/vimrc

~/.vimrc: Keep it simple!

" 设置文件编码检测类型及支持格式
 set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
 
 "显示行号
 set nu!
 
 " 中文帮助
 if version > 603
 set helplang=cn
 endi
 
 " 设置代码自动缩进
 :set cindent
 
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " cscope setting (from http://easwy.com/blog/archives/advanced-vim-skills-cscope/)
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 if has("cscope")
   set csprg=/usr/bin/cscope
   set csto=1
   set cst
   set nocsverb
   " add any database in current directory
   if filereadable("cscope.out")
       cs add cscope.out
   endif
   set csverb
 endif
 
 nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>
 nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR>
 nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR>
 nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR>
 nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR>
 nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
 nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
 nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>
分类: Tools & Tips 标签:

My Ubuntu Installation log

2009年12月18日 Killman 没有评论

业余使用Ubuntu好些年了,装了删删了装的,为了以后方便,把这次的新版本的安装配置过程都记录下来。

第一步,从官方下载 Ubuntu-desktop。

第二步,在VMWare上安装,并安装VMWare-tools。 在ubuntu-desktop-9.10上,不像以前需要手工安装一些包,安装linux头文件,这次一路回车就搞定了。

到这里系统就算安装完毕,发现已经用去了8G硬盘的 37%。

(update 2009-12-28): 事后发现根本没有装好,再次尝试安装,基本上各个模块编译时都会出现error日志,并报告模块没有成功编译。而原来在 ubuntu 8.10下是工作正常的。 为什么升级到 ubuntu 9.10就出错了呢?一开始在网络上搜索,看过 VMware workstation fails after 9.0.4 upgrade to 9.10, 根据该帖建议去打补丁, 但是都没有解决。

后来,去Vmware官方找了下是否有更新,结果发现 VMware Workstationfor Windows 出了新的6.5.3版本, 在 Release Notes 中发现 Ubuntu 9.04 is fully supported. 猜测也许是需要新版本。 尝试下载新版本安装后,重新安装和配置 vmware-tools, 一切顺利!

第三步,安装我需要的各种软件。

0. 设置source.list,我使用 mirrors.163.com.
设置网卡:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.126
netmask 255.255.255.0
gateway 192.168.1.1

#auto eth0
#iface eth0 inet dhcp

1. 安装 vim/ctags/cscope, 设置颜色,缩进等。 The details are noted at Here.

  • install: sudo apt-get install vim
  • Install Chinese vim help: download from http://vimcdoc.sourceforge.net/, tar and enter the directory, execute
  • sudo ./vimcdoc.sh -i
  • sudo apt-get install exuberant-ctags cscope

2. 安装 JDK/C++工具:

sudo apt-get install sun-java6-jdk sun-java6-source
sudo apt-get install build-essential

3. 安装manuals:

开发用的手册页:

sudo apt-get install manpages-dev

安装 Posix 相关的手册页。pthread 库相关的手册页就在这里面,而不在 Dev manual pages 中。

sudo apt-get install manpages-posix manpages-posix-dev

4. 安装版本工具 Subversion 和 Git:

sudo apt-get install subversion subversion-tools git-doc git-core

5. Configure SSH server:

sudo apt-get install openssh-server

.
6. Install LAMP server by tasksel, and configure;
7. 中文支持。我安装系统时用的是英文,因此 LANG=’en_US.UTF-8′。中文输入遵循下面三步骤即可:

  1. Install Simple Chinese Language support.
  2. install: sudo apt-get install scim scim-pinyin
  3. System->Administration->Language Support->Input Method, select scim.
    1. Reboot system, 此时就可以使用智能拼音了。

Resource: SCIM Setup, SCIM Usage

中文问题的解决没有这么简单,还存在下面的问题:

  • gedit不能打开中文文件: 这个文件主要是gedit猜测编码的机制造成的,略加修改就可以。具体参考这里
  • vim不能打开中文文件:Here
  • pdf不能阅读某些中文文件: 问题的症状是能够阅读某些中文pdf,但是还有一些pdf则表现为乱码。问题的原因不太清楚,但是Google后安装了一个新包 poppler-data,就解决了。(sudo apt-get install poppler-data)

8. 安装 CHM 格式文档查看工具 kchmviewer.

sudo apt-get install kchmviewer

但是 kchmviewer 在查看 boost中文文档页时出现了编码错误。当然这不一定就是kchmviewer有问题,也可能是boost中文文档本身的兼容性等。于是另外安装了chmsee, chmsee的另外一个优点就是安装时体积很小,下载过程中才下了几百K。当然也可能是因为我提前把其他需要的库都已经装上了…
9. ruby gems:

sudo apt-get install rubygems1.9.1

10. 声音问题的解决:这里

分类: Tools & Tips 标签:

Vim 快捷键

2009年5月10日 Killman 没有评论

查找

这里有篇介绍文章:VIM下,在文件及目录中查找字符串的方法 。例如: vimgrep /登录/g **/*.html

查找的结果会显示在 QuickList 列表中。对于Quicklist 的操纵,参考下面的文章 打造自己的VIM: QuickFix 編譯視窗 。 这篇文章还介绍了打造快捷键,因为我的Vim使用的版本比较多,而且直接切换到Qucik List然后使用行移动也很方便的,所以就不配置这些快捷键。 更详细的参考见官方手册 Quickfix 或者 :help quickfix

替换 

可以在 vim 中查看帮助 :help argdo

示例:

:args **/*.htm

:argdo %s/旧/新/ge  |  update

翻页

整页翻页 ctrl-f ctrl-b
f就是forword b就是backward

翻半页
ctrl-d ctlr-u
d=down u=up

滚一行
ctrl-e ctrl-y

zz 让光标所杂的行居屏幕中央
zt 让光标所杂的行居屏幕最上一行 t=top
zb 让光标所杂的行居屏幕最下一行 b=bottom

分类: Tools & Tips 标签:

Google搜索使用快捷键

2009年5月9日 Killman 没有评论

Google 搜索支持快捷键,对于只用键盘的人们是十分重要的。

Navigate search results quickly and easily, minimizing use of your mouse. Current keyboard shortcuts include:

Key Action
J Selects the next result.
K Selects the previous result.
O Opens the selected result.
<Enter> Opens the selected result.
/ Puts the cursor in the search box.
<Esc> Removes the cursor from the search box.

默认情况下,谷歌中国的搜索是支持快捷键的,但是 Google.com 不支持。要打开对快捷键的支持,你需要去下面的页面去激活快捷键功能。http://www.google.com/experimental/index.html

参考:

http://www.showsing.net/logs/google-search-of-shortcuts.html

分类: Tools & Tips 标签:

Linux Command & Shell Tips (1)

2009年3月22日 Killman 没有评论

此文用于记录使用 Linux 过程中的与 shell 和 commands 有关的有意思的小知识。

1. The problem of ftp url:
在写一个自动备份的脚本时发现,如果 username 中有 @ 符号时,使用 curl ftp://username:password@host/file 是不行的。这可能是 ftp url 地址格式的一个瑕疵。具体参考 Google Group上的一个讨论 (对于该讨论的正确性本人没有特别考证, 根据作者的观点,在整个URL中出现 “:”、”/”、”@” 都是不可行的。如果您发现此论断有问题请留言)。 还好 curl 可以使用 -n 指定使用 ~/.netrc 中的登录标识。

2. 直接使用 sed 命令批量替换文件中的内容

sed -i 's/\/var\/svn/d:\/data\/svn/g' `grep /var/svn -rl ./*/conf/trac.ini`

sed 命令还有很多用法,可惜平时用得不多,经常忘记了要查资料。

3. 使用 find 命令批量操作 Trac 项目同步SVN

find -maxdepth 1 -mindepth 1  -type d -print -exec trac-admin {} resync \;

对仅仅处理当前目录下的子目录的限定方法比较笨,也许有更好的方法。

4. tar error message.

Removing leading `/’ from member names

It’s really annoying when it present in a crontab script. That is why (refer from here):

what do you want suggestions about? tar archives don’t contain absolute paths, only relative ones. this is correct behaviour, as the alternative is really nasty and illogical. this is the same way that other compression programs like winzip work. when you untar somethign you provide an destination directory, which implicity is ‘/’ in your case… but it should be explicit for logical operation

The resolution is using relative path. e.g.

cd /var/www
tar -cf /home/user/backup/wp-backup.tar web
# NOT below
# cd /home/user/backup
# tar -cf wp-backup.tar /var/www/web

5. svn: Delete unversioned files

svn status --no-ignore | grep '^[I?]' | sed 's/^[I?]//' | xargs rm -rf

Here are more frequent ask questions on subversion.

6. 防火墙后面的git通过代理访问:
设置GIT_PROXY_COMMAND系统变量即可。具体参考:Using Git with a SOCKS proxy

7. Ubuntu添加sudo用户:
Edit file /etc/sudoers, add line:

bob  ALL=(ALL) ALL

参考:http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch09_:_Linux_Users_and_Sudo

分类: Tools & Tips 标签: ,