2018年8月14日

esxi 6.7使用intel p4500 SSD經驗

因為某些因素,使用者指定要裝intel ssd來增加i/o速度,在這邊大概寫一下這一路走來一個月的debug過程

使用工具

  • AS SSD benchmark
  • ATTO disk benchmark

原始環境為esxi 6.5,需要安裝intel P4500 SSD,預設即可使用,不過SSD效能較差,大約用AS SSD測試約只有500MB/s效能。同仁強調該片SSD可測得接近4GB/s的讀取,2GB/s的寫入效能,故希望改善。以下為所有測試紀錄

  1. 查網站文件指出intel已無提供給esxi使用的驅動程式,在vmware官網上唯一提供的NVMe驅動只能用在esxi 6.7上,嘗試用esxi 6.5吃 for esxi 6.7用的NVMe驅動
    結果:失敗
  2. 升版至esxi 6.7,測試SSD讀寫效能仍不佳
    結果:失敗
  3. 安裝vmware官網釋出的NVMe驅動 intel-nvme-vmd version 1.4.0.1016,讀寫效能佳,但...會當機
    結果:大失敗

    ...無止盡測試SSD
  4. 更新esxi 6.7最新釋出patch,仍當
    結果:失敗
  5. 更新SSD firmware,需安裝Intel® SSD Data Center Tool 3.0.14
    結果:持續運作測試中,幹...無效
-------------------------
SSD更新動作log
  1. vib install
  2. /opt/intel/isdct/isdct show -all -intelssd
    show ssd 查出要升級的該片SSD index
  3. /opt/intel/isdct/isdct load -intelssd 0
    用load指令升級ssd firmware,後面0為該片ssd index
SSD需要分多次升級,所以esxi會反覆重開




2018年4月25日

vcsa問題 Unable to load resource module from /vsphere-client/VDP2/locales/VDP-zh_TW.swf

VDP因為沒有zh_TW語系,所以只要裝了VDP後,vCenter一定會出現無法找到zh_TW語系
沒有治本方法,只有治標方法如下 (重開機後系統會還原,還好vc重開機會不多)

1.SSH登入VCSA主機
2.找出語系檔放置目錄
3.拷貝zh_CN成zh_TW


root@VCSA [ ~ ]# find / -name VDP-en_US.swf

/usr/lib/vmware-vsphere-client/server/work/deployer/s/global/124/0/vdr-ui-war-6.1.6.war/locales/VDP-en_US.swf

root@VCSA [ ~ ]# cd /usr/lib/vmware-vsphere-client/server/work/deployer/s/global/124/0/vdr-ui-war-6.1.6.war/locales/

root@VCSA [ /usr/lib/vmware-vsphere-client/server/work/deployer/s/global/124/0/vdr-ui-war-6.1.6.war/locales ]# cp VDP-zh_CN.swf VDP-zh_TW.swf


2018年3月8日

vm升級方法

1. 下載offline bundle,放到資料存放區
2. esxcli software sources profile list -d "Offline Bundle 路徑"
3. esxcli software profile update -d "Offline Bundle 路徑" -p "Profile 名稱"

或,使用下列網站
https://esxi-patches.v-front.de/ESXi-6.0.0.html



2017年4月21日

尋找linux肥大檔案

1.
du -h --max-depth=1
max-depth是表示查詢子目錄的層級
就可查到目錄佔用的情形,再到較大的目錄,重覆利用此指令去找出佔用較大的檔案

vm開機進BIOS選單

因為最近被Assign管VM,所以來寫一些VM常見的小bug排除

1. VM開機要怎樣進BIOS選項
A:更改該虛擬機器附檔名為vmx的資料設定檔案,並在檔案最後,加入下面的指令後儲存檔案:bios.bootDelay = "10000"

2.cluster警示沒有重複網路
A:將cluster HA進階選項新增值das.ignoreRedundantNetWarning true

3.vSphere更新
A:https://esxi-patches.v-front.de/


2015年5月8日

brocade ntp time

Synchronizing local time using NTP

Perform the following steps to synchronize the local time using NTP.
  1. Log into the switch using the default password, which is password.
  2. Enter the tsClockServer command:
    switch:admin> tsclockserver  ""
    
    where ntp1 is the IP address or DNS name of the first NTP server, which the switch must be able to access. The second ntp2 is the second NTP server and is optional. The operand "" is optional; by default, this value is LOCL, which uses the local clock of the principal or primary switch as the clock server.
    switch:admin> tsclockserver
    LOCL
    switch:admin> tsclockserver "132.163.135.131"
     
    switch:admin> tsclockserver
    132.163.135.131
    switch:admin>
    The following example shows how to set up more than one NTP server using a DNS name:
    switch:admin> tsclockserver
     "10.32.170.1;10.32.170.2;ntp.localdomain.net"
    Updating Clock Server configuration...done.
    Updated with the NTP servers
    Changes to the clock server value on the principal or primary FCS switch are propagated to all switches in the fabric.

2015年4月28日

fio效能測試手記

FIO安裝測試範例
[root@supermic2 ~]#
[root@supermic2 ~]# mkdir fio
[root@supermic2 ~]# cd fio/
[root@supermic2 fio]# wget ftp://195.220.108.108/linux/dag/redhat/el7/en/x86_64/dag/RPMS/fio-2.1.10-1.el7.rf.x86_64.rpm
[root@supermic2 fio]# rpm -ivh fio-2.1.10-1.el7.rf.x86_64.rpm
warning: fio-2.1.10-1.el7.rf.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
error: Failed dependencies:
        libc.so.6(GLIBC_2.14)(64bit) is needed by fio-2.1.10-1.el7.rf.x86_64
        libm.so.6(GLIBC_2.15)(64bit) is needed by fio-2.1.10-1.el7.rf.x86_64
請勿跟我一樣犯傻裝成RHEL7
[root@supermic2 fio]# wget ftp://195.220.108.108/linux/dag/redhat/el6/en/x86_64/dag/RPMS/fio-2.1.10-1.el6.rf.x86_64.rpm
[root@supermic2 fio]# rpm -ivh fio-2.1.10-1.el6.rf.x86_64.rpm
warning: fio-2.1.10-1.el6.rf.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
error: Failed dependencies:
        libibverbs.so.1()(64bit) is needed by fio-2.1.10-1.el6.rf.x86_64
[root@supermic2 fio]# yum install libibverbs
[root@supermic2 fio]# rpm -ivh fio-2.1.10-1.el6.rf.x86_64.rpm

powerpath
[root@supermic2 ~]# wget https://www.dropbox.com/s/na23jm0w4s6hikx/EMCPower.LINUX-6.0.0.00.00-158.RHEL6.x86_64.rpm
[root@supermic2 ~]# rpm -ivh EMCPower.LINUX-6.0.0.00.00-158.RHEL6.x86_64.rpm
[root@supermic2 ~]# emcpreg -i
Reboot
[root@supermic2 ~]# powermt display dev=all
Pseudo name=emcpowera
VNX ID=CETV2150900078 [SG_Test]
Logical device ID=60060160E1603C00BC6C544A52EDE411 [SPMIC4-2_1TB_IOPS_Test]
state=alive; policy=CLAROpt; queued-IOs=0
Owner: default=SP B, current=SP B       Array failover mode: 4
==============================================================================
--------------- Host ---------------   - Stor -  -- I/O Path --   -- Stats ---
###  HW Path               I/O Paths    Interf.  Mode     State   Q-IOs Errors
==============================================================================
   1 bfa                    sda        SP A0     active   alive      0      0
   1 bfa                    sdb        SP B0     active   alive      0      0

[root@supermic2 ~]# cd /dev/
[root@supermic2 dev]# mkfs -t ext4 /dev/emcpowera
[root@supermic2 dev]# mkdir /emcdisk
[root@supermic2 dev]# mount /dev/emcpowera /emcdisk/
[root@supermic2 dev]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdc3       450G  2.1G  426G   1% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
/dev/sdc1       477M   63M  389M  14% /boot
/dev/emcpowera 1008G   72M  957G   1% /emcdisk
測試FIO效能
[root@supermic2 emcdisk]# fio -filename=/dev/emcpowera -direct=1 -iodepth 1 -thread -rw=randrw -rwmixread=70 -ioengine=psync -bs=16k -size=64G -numjobs=30 -runtime=100 -group_reporting -name=mytest
mytest: (g=0): rw=randrw, bs=16K-16K/16K-16K/16K-16K, ioengine=psync, iodepth=1
...
fio-2.1.10
Starting 30 threads
Jobs: 30 (f=30): [mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm] [100.0% done] [116.6MB/52576KB/0KB /s] [7460/3286/0 iops] [eta 00m:00s]
mytest: (groupid=0, jobs=30): err= 0: pid=8028: Tue Apr 28 11:47:30 2015
  read : io=16586MB, bw=169621KB/s, iops=10601, runt=100130msec
    clat (usec): min=140, max=367472, avg=1137.68, stdev=2374.99
     lat (usec): min=140, max=367472, avg=1137.94, stdev=2374.99
    clat percentiles (usec):
     |  1.00th=[  374],  5.00th=[  470], 10.00th=[  524], 20.00th=[  604],
     | 30.00th=[  692], 40.00th=[  772], 50.00th=[  852], 60.00th=[  948],
     | 70.00th=[ 1048], 80.00th=[ 1176], 90.00th=[ 1368], 95.00th=[ 1576],
     | 99.00th=[ 9920], 99.50th=[13632], 99.90th=[27008], 99.95th=[34560],
     | 99.99th=[62720]
    bw (KB  /s): min=  504, max= 8032, per=3.34%, avg=5673.48, stdev=882.68
  write: io=7098.6MB, bw=72595KB/s, iops=4537, runt=100130msec
    clat (usec): min=414, max=325774, avg=3931.50, stdev=4172.32
     lat (usec): min=415, max=325775, avg=3932.92, stdev=4172.32
    clat percentiles (usec):
     |  1.00th=[ 1064],  5.00th=[ 1592], 10.00th=[ 2008], 20.00th=[ 2512],
     | 30.00th=[ 2896], 40.00th=[ 3216], 50.00th=[ 3568], 60.00th=[ 3920],
     | 70.00th=[ 4384], 80.00th=[ 4960], 90.00th=[ 5792], 95.00th=[ 6560],
     | 99.00th=[10048], 99.50th=[14144], 99.90th=[48384], 99.95th=[79360],
     | 99.99th=[168960]
    bw (KB  /s): min=   94, max= 3424, per=3.34%, avg=2427.76, stdev=361.93
    lat (usec) : 250=0.07%, 500=5.30%, 750=20.54%, 1000=20.27%
    lat (msec) : 2=24.73%, 4=16.11%, 10=11.99%, 20=0.78%, 50=0.19%
    lat (msec) : 100=0.03%, 250=0.01%, 500=0.01%
  cpu          : usr=0.28%, sys=1.53%, ctx=1533832, majf=0, minf=6
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued    : total=r=1061507/w=454307/d=0, short=r=0/w=0/d=0
     latency   : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):
   READ: io=16586MB, aggrb=169620KB/s, minb=169620KB/s, maxb=169620KB/s, mint=100130msec, maxt=100130msec
  WRITE: io=7098.6MB, aggrb=72594KB/s, minb=72594KB/s, maxb=72594KB/s, mint=100130msec, maxt=100130msec

Disk stats (read/write):
  emcpowera: ios=1060910/454033, merge=0/2, ticks=1184825/1769804, in_queue=2952885, util=99.95%

[root@supermic2 emcdisk]#
================================
參考網誌
http://www.cnblogs.com/Skyar/p/3488100.html

2014年12月7日

安裝 Telnet 用戶端

http://technet.microsoft.com/zh-tw/library/cc771275%28v=ws.10%29.aspx
=======================================

安裝 Telnet 用戶端

本主題尚未接受評分 為這個主題評分
更新日期: 2010年3月
適用於: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
Windows Vista 或 Windows Server 2008 預設不會安裝 Telnet 用戶端。Telnet 用戶端的安裝程序視您使用的作業系統而定:
若要完成此程序,您必須至少是本機Administrators 群組成員,或同等群組成員。

使用命令列安裝 Telnet 用戶端

在 Windows Server 2008 或 Windows Vista 上,您可以使用以下命令列程序來安裝 Telnet 用戶端。

使用命令列安裝 Telnet 用戶端

  1. 開啟 [命令提示字元] 視窗。按一下 [開始],在 [開始搜尋] 方塊中輸入 cmd,然後按下 ENTER
  2. 輸入下列命令:
    pkgmgr /iu:"TelnetClient"
    
  3. 如果出現 [使用者帳戶控制] 對話方塊,請確認顯示的動作為所需動作,然後按一下 [繼續]。
  4. 當命令提示字元再次出現時,表示已安裝完成。

在 Windows Server 2008 上安裝 Telnet 用戶端

在 Windows Server 2008 上,您可以使用 [角色管理] 工具來安裝選用元件。

在 Windows Server 2008 上安裝 Telnet 用戶端

  1. 啟動 [伺服器管理員]。按一下 [開始],在 [電腦] 上按一下滑鼠右鍵,然後按一下 [管理]
  2. 如果出現 [使用者帳戶控制] 對話方塊,請確認顯示的動作為所需動作,然後按一下 [繼續]。
  3. 在 [功能摘要] 區段中,按一下 [新增功能]
  4. 在 [新增功能精靈] 中,選取 [Telnet 用戶端],然後按 [下一步]
  5. 在 [確認安裝選項] 頁面上,按一下 [安裝]
  6. 安裝完成時,請按一下 [安裝結果] 頁面上的 [關閉]

在 Windows Vista 上安裝 Telnet 用戶端

在 Windows Vista 上,您可以使用 [Windows 功能] 工具來安裝選用元件。

在 Windows Vista 上安裝 Telnet 用戶端

  1. 按一下 [開始],然後按一下 [控制台]
  2. 按一下 [控制台首頁] 頁面中的 [程式集]
  3. 在 [程式和功能] 區段中,按一下 [開啟或關閉 Windows 功能]
  4. 如果出現 [使用者帳戶控制] 對話方塊,請確認顯示的動作為所需動作,然後按一下 [繼續]。
  5. 在 [Windows 功能] 清單中,選取 [Telnet 用戶端],然後按一下 [確定]

2014年10月13日

linux install xrdp

使用預設yum repolist無此套件
[root@localhost ~]# yum install xrdp

顯示repolist
[root@localhost yum.repos.d]# yum repolist

下載並安裝fedora擴充repolist
[root@localhost ~]# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@localhost ~]# rpm -ivh epel-release-6-8.noarch.rpm

可用yum安裝
[root@localhost ~]# yum install xrdp

啟動xrdp
[root@localhost ~]# service xrdp start

新增防火牆
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3389 -j ACCEPT
service iptables save
service iptables restart

2014年9月23日

使用 telnet 測試 SMTP 步驟及方法

懶了,轉別人文章
http://erichuang89.blogspot.tw/2008/08/telnet-smtp.html
=========================================

使用 telnet 測試 SMTP 步驟及方法

當要測試 mail 功能是否正常最方便的莫過於用 telnet 。這程式
比用 outlook express 等其他 MUA (mail user agent) 程式更方便。
在 9X , XP 都有提供 telnet 程式 , 在<開始> <執行> 打入 telnet 即可 .

在 vista 就比較麻煩 , 因為vista 把 telnet client 程式拿掉 , 必須自己載入這好用的小程式 .
因為在日常工作中許多地方都必須用到 telnet client ,就把它安裝上去。

步驟 : <控制台> - <程式和功能> - <開啟或關閉 windows 功能> 勾選
如圖 :












測試方法 :
以下指令是用於各MAIL系統 但因為 不同的系統主機回應的文字不同 但是前面的
代碼 <220> 都是一樣,不同的只有後面所顯示的文字 。

本範例以 POSTFIX 為例
1. telnet hostname.domain.XXX 25
主機回應 220 hostname.domain.xxx ESMTP Postfix

2. helo hostname
主機回應 250 hostname.domain.xxx

3. mail from:youname@mailaddress //寄件者
主機回應 250 2.1.0 Ok

4. rcpt to:username@mailaddress //收信者
主機回應 250 2.1.0 Ok

5. data
開始寫信
subject: test mail
.................

6. 結束寫信用 " . "

7. quit
離開

2014年5月26日

2014 報稅軟體 亂碼

來自台中的黏小姐發問
==============================
Q:為什麼我的報稅軟體打開後是亂碼,我的語系都是設定台灣啊
A:這是個很清楚的人品問題...
==============================
拉奇大神解答如下
因為windows太爛或是報稅軟體太爛,你只要先把設定調到香港再調回來就解決拉...

2014年5月5日

tsm client install with ubuntu 64

前言

ubuntu 13.04以後已經不support ia32-libs,所以之後的要怎樣跑64bit的client還要try
ubuntu 11.04 apt-get一直search不到更新來源,還要確認更舊版本是否有問題

===================================================================

root@ubuntu:~# apt-get install alien libstdc++5 ksh ia32-libs

root@ubuntu:~# tar xvf 5.5.4.0-TIV-TSMBAC-LinuxX86.tar
NOTICES.TXT
README_enu.htm
README_api_enu.htm
README_hsm_enu.htm
TIVsm-API.i386.rpm
TIVsm-API64.rpm
TIVsm-BA.i386.rpm
TIVsm-HSM.i386.rpm

root@ubuntu:~# alien -g TIVsm-API.i386.rpm
Warning: Skipping conversion of scripts in package TIVsm-API: postinst prerm
Warning: Use the --scripts parameter to include the scripts.
Directories TIVsm-API-5.5.4 and TIVsm-API-5.5.4.orig prepared.

root@ubuntu:~# alien -g TIVsm-BA.i386.rpm
Warning: Skipping conversion of scripts in package TIVsm-BA: postinst prerm
Warning: Use the --scripts parameter to include the scripts.
Directories TIVsm-BA-5.5.4 and TIVsm-BA-5.5.4.orig prepared.

root@ubuntu:~# mv TIVsm-API-5.5.4/debian/ TIVsm-API-5.5.4/DEBIAN
root@ubuntu:~# mv TIVsm-BA-5.5.4/debian/ TIVsm-BA-5.5.4/DEBIAN

root@ubuntu:~# vi TIVsm-API-5.5.4/DEBIAN/control
root@ubuntu:~# vi TIVsm-API-5.5.4/DEBIAN/control

root@ubuntu:~# dpkg -b TIVsm-API-5.5.4
dpkg-deb: error: maintainer script `postinst' has bad permissions 644 (must be >=0555 and <=0775)
root@ubuntu:~# chmod 755 TIVsm-API-5.5.4/DEBIAN/postinst
root@ubuntu:~# chmod 755 TIVsm-BA-5.5.4/DEBIAN/postinst
root@ubuntu:~# dpkg -b TIVsm-API-5.5.4
root@ubuntu:~# dpkg -b TIVsm-BA-5.5.4

root@ubuntu:~# echo "/opt/tivoli/tsm/client/api/bin" >> /etc/ld.so.conf.d/tsm-api.conf
root@ubuntu:~# ldconfig

root@ubuntu:~# dpkg -i TIVsm-API-5.5.4.deb
root@ubuntu:~# dpkg -i TIVsm-BA-5.5.4.deb

root@ubuntu:~# cd /opt/tivoli/tsm/client/ba/bin/
root@ubuntu:/opt/tivoli/tsm/client/ba/bin# cp dsm.sys.smp dsm.sys
root@ubuntu:/opt/tivoli/tsm/client/ba/bin# cp dsm.opt.smp dsm.opt
root@ubuntu:/opt/tivoli/tsm/client/ba/bin# chmod 755 dsm.sys
root@ubuntu:/opt/tivoli/tsm/client/ba/bin# chmod 755 dsm.opt
root@ubuntu:/opt/tivoli/tsm/client/ba/bin# vi dsm.sys

root@ubuntu:~# dsmc
dsmc: error while loading shared libraries: libgpfs.so: cannot open shared object file: No such file or directory

root@ubuntu:~# ln -s /opt/tivoli/tsm/client/api/bin/libgpfs.so /lib/
root@ubuntu:~# ln -s /opt/tivoli/tsm/client/api/bin/libdmapi.so /lib/
root@ubuntu:~# ln -s /opt/tivoli/tsm/client/api/bin/libha_gs_r.so /lib/
root@ubuntu:~# ln -s /opt/tivoli/tsm/client/api/bin/libct_cu.so /lib/


root@ubuntu:~# dsmc
IBM Tivoli Storage Manager
Command Line Backup/Archive Client Interface
  Client Version 5, Release 5, Level 4.0
  Client date/time: 05/06/2014 09:46:48
(c) Copyright by IBM Corporation and other(s) 1990, 2012. All Rights Reserved.

Node Name: PAN660-3
Please enter your user id

Please enter password for user id "PAN660-3":

Session established with server TSM2: Linux/x86_64
  Server Version 6, Release 3, Level 3.0
  Server date/time: 05/06/2014 09:46:47  Last access: 05/06/2014 09:46:38

tsm> inc /


Incremental backup of volume '/'
ANS1898I ***** Processed     6,000 files *****
Directory-->               4,096 / [Sent]    
Directory-->               4,096 /bin [Sent]    
Directory-->               4,096 /boot [Sent]    
...
...
...
Directory-->               4,096 /var/spool/cron/atjobs [Sent]    
Directory-->               4,096 /var/spool/cron/atspool [Sent]    
Directory-->               4,096 /var/spool/cron/crontabs [Sent]    
Normal File-->                 2 /var/spool/cron/atjobs/.SEQ [Sent]    
Successful incremental backup of '/'

                                 

Total number of objects inspected:   69,618
Total number of objects backed up:   69,618
Total number of objects updated:          0
Total number of objects rebound:          0
Total number of objects deleted:          0
Total number of objects expired:          0
Total number of objects failed:           0
Total number of bytes transferred:    1.67 GB
Data transfer time:                   19.07 sec
Network data transfer rate:        92,190.76 KB/sec
Aggregate data transfer rate:      25,550.86 KB/sec
Objects compressed by:                    0%
Elapsed processing time:           00:01:08
tsm> quit

root@ubuntu:~#

2014年2月10日

vim用法

http://blog.eddie.com.tw/2011/12/28/vim-tips/

=============轉貼==============


Vim的操作小技巧

Vim的操作除了基本的hjkl之外,快速鍵組合相當多,不過大概有個規則。以下是我自己個人比較常會用到,而且覺得還滿方便的操作小技巧,寫起來幫自己加深記憶,希望也對有需要的朋友有幫助。

說明

  1. Enter = 按下enter鍵,Ctrl = 按下ctrl鍵,Alt = 按下alt鍵,如果是大寫字母例如G = shift + g,Ctrlwj = 按著ctrl鍵不放,再按下w,再按下j
  2. 這裡提到的都是Vim或是plugin內建的指令,如果你不喜歡或覺得難按,可以透過修改.vimrc來改變快速鍵的對映
  3. 以下指令都是在一般模式(Normal Mode)下使用

游標移動

  • gg = 移到整份文件的最上方
  • G = 移到整份文件的最下方
  • H = 移到目前螢幕的最上方
  • L = 移到目前螢幕的最下方
  • 10Enter = 游標往下移動10行,前面的數字表示行數
  • :10Enter = 游標直接移動到第10行
  • {} = 把游標移動到上一個、下一個段落
  • Ctrlwj = 把游標往下面的分割視窗移動
  • Ctrlwk = 把游標往上面的分割視窗移動
  • Ctrlwh = 把游標往左邊的分割視窗移動
  • Ctrlww = 在各個分割視窗間切換
建議可以搭配 EasyMotion 更有效率的移動游標

搜尋

  • / = 搜尋
  • * = 移往下一個搜尋結果
  • # = 移往上一個搜尋結果

編輯

  • u = undo,回到上一步
  • Ctrlr = redo,回復undo
  • . = 重複上一個步驟
  • ~ = 改變英文字母的大小寫,本來大寫會變小寫,小寫會變大寫
  • :m+ = 把目前這一行往下移動一行
  • :m-2 = 把目前這一行往上移動一行
  • >><< = 增加、減少縮排
  • yyY = 複製游標所在的這一整行
  • pP = 在游標之後、之前貼上複製的內容
  • "ayy = 跟yy有點像,但是是把複製的東西放到a 暫存器裡,這個a可以用其它25個英文字母代替,可以用:reg指令把目前的暫存器叫出來看
  • "ap = 在游標之後貼上a 暫存器裡的內容

模式切換

  • Esc 或 Ctrl[ = 回到命令模式,ESC是獨立一顆比較好按,但比較遠,如果你不想讓你的手離開打字區的話,可以選用CTRL [,或是在~/.vimrc裡自訂快速鍵
  • Ctrlv = visual block模式,可進行像TextMate按住alt鍵的區塊選取

NERDTree

  • B = 叫出bookmark
  • C = 把目前游標停留的這個目錄設定為根目錄
  • p = 把游標移動到上一層目錄
  • P = 把游標移動到根目錄
  • J = 把游標移往這個結點的第一個
  • K = 把游標移往這個結點的最後一個
  • u = 把樹狀結構的根目錄往上移一層
  • I = 切換是否顯示隱藏檔案
  • m = 叫出NERDTree的系統選單

其它

  • :! = 執行外部指令,例如:!ls則是執行ls指令

參考資料

這裡有幾篇我覺得寫得很棒的文章,可以更清楚的知道在Vim裡操作的原理
Vim的快速鍵組合如果用得熟的話,整個編輯的過程中是幾乎可以不動到滑鼠的,不過還是要多練習啦,差不多練到跟吃飯睡覺一樣熟練就可以了。打完收工 :wq