Tuesday, January 30, 2007

 

Vim Commands Cheat Sheet

How to Exit

:q[uit] Quit Vim. This fails when changes have been made.
:q[uit]! Quit without writing.
:cq[uit] Quit always, without writing.
:wq Write the current file and exit.
:wq! Write the current file and exit always.
:wq {file} Write to {file}. Exit if not editing the last
:wq! {file} Write to {file} and exit always.
:[range]wq[!] [file] Same as above, but only write the lines in [range].
ZZ Write current file, if modified, and exit.
ZQ Quit current file and exit (same as ":q!").


Editing a File

:e[dit] Edit the current file. This is useful to re-edit the current file, when it has been changed outside of Vim.
:e[dit]! Edit the current file always. Discard any changes to the current buffer. This is useful if you want to start all over again.
:e[dit] {file} Edit {file}.
:e[dit]! {file} Edit {file} always. Discard any changes to the current buffer.
gf Edit the file whose name is under or after the cursor. Mnemonic: "goto file".


Inserting Text

a Append text after the cursor [count] times.
A Append text at the end of the line [count] times.
i Insert text before the cursor [count] times.
I Insert text before the first non-blank in the line [count] times.
gI Insert text in column 1 [count] times.
o Begin a new line below the cursor and insert text, repeat [count] times.
O Begin a new line above the cursor and insert text, repeat [count] times.


Inserting a file

:r[ead] [name] Insert the file [name] below the cursor.
:r[ead] !{cmd} Execute {cmd} and insert its standard output below the cursor.


Deleting Text

<> or
x
Delete [count] characters under and after the cursor
X Delete [count] characters before the cursor
d{motion} Delete text that {motion} moves over
dd Delete [count] lines
D Delete the characters under the cursor until the end of the line
{Visual}x or
{Visual}d
Delete the highlighted text (for {Visual} see Selecting Text).
{Visual}CTRL-H or
{Visual}
When in Select mode: Delete the highlighted text
{Visual}X or
{Visual}D
Delete the highlighted lines
:[range]d[elete] Delete [range] lines (default: current line)
:[range]d[elete] {count} Delete {count} lines, starting with [range]


Changing (or Replacing) Text

r{char} replace the character under the cursor with {char}.
R Enter Insert mode, replacing characters rather than inserting
~ Switch case of the character under the cursor and move the cursor to the right. If a [count] is given, do that many characters.
~{motion} switch case of {motion} text.
{Visual}~ Switch case of highlighted text


Substituting

:[range]s[ubstitute]/{pattern}/{string}/[c][e][g][p][r][i][I] [count] For each line in [range] replace a match of {pattern} with {string}.
:[range]s[ubstitute] [c][e][g][r][i][I] [count] :[range]&[c][e][g][r][i][I] [count] Repeat last :substitute with same search pattern and substitute string, but without the same flags. You may add extra flags

The arguments that you can use for the substitute commands:
[c] Confirm each substitution. Vim positions the cursor on the matching
string. You can type:
'y' to substitute this match
'n' to skip this match
to skip this match
'a' to substitute this and all remaining matches {not in Vi}
'q' to quit substituting {not in Vi}
CTRL-E to scroll the screen up {not in Vi}
CTRL-Y to scroll the screen down {not in Vi}.
[e] When the search pattern fails, do not issue an error message and, in
particular, continue in maps as if no error occurred.
[g] Replace all occurrences in the line. Without this argument,
replacement occurs only for the first occurrence in each line.
[i] Ignore case for the pattern.
[I] Don't ignore case for the pattern.
[p] Print the line containing the last substitute.

Copying and Moving Text

"{a-zA-Z0-9.%#:-"} Use register {a-zA-Z0-9.%#:-"} for next delete, yank or put (use uppercase character to append with delete and yank) ({.%#:} only work with put).
:reg[isters] Display the contents of all numbered and named registers.
:reg[isters] {arg} Display the contents of the numbered and named registers that are mentioned in {arg}.
:di[splay] [arg] Same as :registers.
["x]y{motion} Yank {motion} text [into register x].
["x]yy Yank [count] lines [into register x]
["x]Y yank [count] lines [into register x] (synonym for yy).
{Visual}["x]y Yank the highlighted text [into register x] (for {Visual} see Selecting Text).
{Visual}["x]Y Yank the highlighted lines [into register x]
:[range]y[ank] [x] Yank [range] lines [into register x].
:[range]y[ank] [x] {count} Yank {count} lines, starting with last line number in [range] (default: current line), [into register x].
["x]p Put the text [from register x] after the cursor [count] times.
["x]P Put the text [from register x] before the cursor [count] times.
["x]gp Just like "p", but leave the cursor just after the new text.
["x]gP Just like "P", but leave the cursor just after the new text.
:[line]pu[t] [x] Put the text [from register x] after [line] (default current line).
:[line]pu[t]! [x] Put the text [from register x] before [line] (default current line).


Undo/Redo/Repeat

u Undo [count] changes.
:u[ndo] Undo one change.
CTRL-R Redo [count] changes which were undone.
:red[o] Redo one change which was undone.
U Undo all latest changes on one line. {Vi: while not moved off of it}
. Repeat last change, with count replaced with [count].


Moving Around

Basic motion commands:

k
h l
j

h or
[count] characters to the left (exclusive).
l or
or
[count] characters to the right (exclusive).
k or
or
CTRL-P
[count] lines upward
j or
or
CTRL-J or
or
CTRL-N
[count] lines downward (linewise).
0 To the first character of the line (exclusive).
To the first character of the line (exclusive).
^ To the first non-blank character of the line
$ or
To the end of the line and [count - 1] lines downward
g0 or
g
When lines wrap ('wrap on): To the first character of the screen line (exclusive). Differs from "0" when a line is wider than the screen. When lines don't wrap ('wrap' off): To the leftmost character of the current line that is on the screen. Differs from "0" when the first character of the line is not on the screen.
g^ When lines wrap ('wrap' on): To the first non-blank character of the screen line (exclusive). Differs from "^" when a line is wider than the screen. When lines don't wrap ('wrap' off): To the leftmost non-blank character of the current line that is on the screen. Differs from "^" when the first non-blank character of the line is not on the screen.
g$ or
g< end&gr;
When lines wrap ('wrap' on): To the last character of the screen line and [count - 1] screen lines downward (inclusive). Differs from "$" when a line is wider than the screen. When lines don't wrap ('wrap' off): To the rightmost character of the current line that is visible on the screen. Differs from "$" when the last character of the line is not on the screen or when a count is used.
f{char} To [count]'th occurrence of {char} to the right. The cursor is placed on {char} (inclusive).
F{char} To the [count]'th occurrence of {char} to the left. The cursor is placed on {char} (inclusive).
t{char} Till before [count]'th occurrence of {char} to the right. The cursor is placed on the character left of {char} (inclusive).
T{char} Till after [count]'th occurrence of {char} to the left. The cursor is placed on the character right of {char} (inclusive).
; Repeat latest f, t, F or T [count] times.
, Repeat latest f, t, F or T in opposite direction [count] times.
- [count] lines upward, on the first non-blank character (linewise).
+ or
CTRL-M or
[count] lines downward, on the first non-blank character (linewise).
_ [count] - 1 lines downward, on the first non-blank character (linewise).
or
G
Goto line [count], default last line, on the first non-blank character.
or
gg
Goto line [count], default first line, on the first non-blank character.
or
w
[count] words forward
or
W
[count] WORDS forward
e Forward to the end of word [count]
E Forward to the end of WORD [count]
or
b
[count] words backward
or
B
[count] WORDS backward
ge Backward to the end of word [count]
gE Backward to the end of WORD [count]
These commands move over words or WORDS.

A word consists of a sequence of letters, digits and underscores, or a sequence of other non-blank characters, separated with white space (spaces, tabs, ). This can be changed with the 'iskeyword' option.

A WORD consists of a sequence of non-blank characters, separated with white space. An empty line is also considered to be a word and a WORD.

( [count] sentences backward
) [count] sentences forward
{ [count] paragraphs backward
} [count] paragraphs forward
]] [count] sections forward or to the next '{' in the first column. When used after an operator, then the '}' in the first column.
][ [count] sections forward or to the next '}' in the first column
[[ [count] sections backward or to the previous '{' in the first column
[] [count] sections backward or to the previous '}' in the first column

Marks

m{a-zA-Z} Set mark {a-zA-Z} at cursor position (does not move the cursor, this is not a motion command).
m' or
m`
Set the previous context mark. This can be jumped to with the "''" or "``" command (does not move the cursor, this is not a motion command).
:[range]ma[rk] {a-zA-Z} Set mark {a-zA-Z} at last line number in [range], column 0. Default is cursor line.
:[range]k{a-zA-Z} Same as :mark, but the space before the mark name can be omitted.
'{a-z} To the first non-blank character on the line with mark {a-z} (linewise).
'{A-Z0-9} To the first non-blank character on the line with mark {A-Z0-9} in the correct file
`{a-z} To the mark {a-z}
`{A-Z0-9} To the mark {A-Z0-9} in the correct file
:marks List all the current marks (not a motion command).
:marks {arg} List the marks that are mentioned in {arg} (not a motion command). For example:


Searching

/{pattern}[/] Search forward for the [count]'th occurrence of {pattern}
/{pattern}/{offset} Search forward for the [count]'th occurrence of {pattern} and go {offset} lines up or down.
/ Search forward for the [count]'th latest used pattern
//{offset} Search forward for the [count]'th latest used pattern with new. If {offset} is empty no offset is used.
?{pattern}[?] Search backward for the [count]'th previous occurrence of {pattern}
?{pattern}?{offset} Search backward for the [count]'th previous occurrence of {pattern} and go {offset} lines up or down
? Search backward for the [count]'th latest used pattern
??{offset} Search backward for the [count]'th latest used pattern with new {offset}. If {offset} is empty no offset is used.
n Repeat the latest "/" or "?" [count] times.
N Repeat the latest "/" or "?" [count] times in opposite direction.


Selecting Text (Visual Mode)

To select text, enter visual mode with one of the commands below, and use motion commands to highlight the text you are interested in. Then, use some command on the text.

The operators that can be used are:
~ switch case
d delete
c change
y yank
> shift right
< shift left
! filter through external command
= filter through 'equalprg' option command
gq format lines to 'textwidth' length
v start Visual mode per character.
V start Visual mode linewise.
exit Visual mode without making any changes

How to Suspend

CTRL-Z Suspend Vim, like ":stop". Works in Normal and in Visual mode. In Insert and Command-line mode, the CTRL-Z is inserted as a normal character.
:sus[pend][!] or
:st[op][!]
Suspend Vim. If the '!' is not given and 'autowrite' is set, every buffer with changes and a file name is written out. If the '!' is given or 'autowrite' is not set, changed buffers are not written, don't forget to bring Vim back to the foreground later!

Monday, January 29, 2007

 

easywine

deb package for ubuntu
deb http://archive.ubuntu.org.cn/ubuntu-cn edgy main universe multiverse restricted

Sunday, January 28, 2007

 

remove the "update-manager"

rm -f /root/etc/xdg/autostart/update-notifier.desktop
rm -f /root/usr/share/autostart/adept_notifier_auto.desktop

Thursday, January 25, 2007

 

colourshell.sh

# colourshell.sh

# Please copy these into a file named .colourshell.sh at home. Then plus ". .colourshell.sh"
# to the the .bashrc.

# In an interactive Bash shell, cycles through a sequence of colours,
# one per command, so that you can more easily see where one finishes
# and the next starts.

# (C) 2006 Philip Endecott
# See http://chezphil.org/colourshell/ for more information.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


# As far as I'm aware this won't work in any shells other than bash
# because it uses bash-specific features.

# To try it out, source this file into an interactive shell:
# source /path/to/colourshell.sh

# For permanent use this file should be sourced from your bash startup
# script(s).
#
# Bash may execute various different startup scripts; see the
# INVOCATION section of the bash man page for details. To have this
# script called for both login shells (e.g. virtual consoles) and
# non-login shells (e.g. xterms) you need to call it from both
# .bash_profile and .bashrc. .bashrc may also be called for
# non-interactive shells; to avoid running this in that case you can
# enclose the source command in an if block that tests for
# interactivity by checking for PS1:
#
# if [ "$PS1" ]
# then
# source /path/to/colourshell.sh
# fi

# Source this from somewhere near the end of those files. In
# particular, source it from after any code that sets the prompt
# variables (PS1 etc.) since this code adds its stuff to the existing
# PS1 setting.

# If your startup scripts don't set PS1 to PS4, things could get
# interesting if you start one shell inside another: this code will be
# called twice! It should still work, but ideally this script would
# scrub any existing colour-setting codes from the prompts before
# adding its own.

# This code generates colour-changing escape sequences using the tput
# program. This is a simple utility that uses the termcap database to
# look up escape sequences for the current terminal. It seems to be
# included in the major Linux distributions. For details, see "man
# tput" and "man 5 terminfo". In particular see the "Color Handling"
# section of "man 5 terminfo".

# Most terminals with colour support have 8 colours. An exception is
# rxvt-unicode (and other rxvts?) which claims to have 88. This script
# doesn't know what to do with any other cases, so gives up immediately
# without error.

ncolours=`tput colors`
case $ncolours in
8) ;;
88) ;;
*) return 0 ;;
esac

# The following are the standard colour codes; see "man 5 terminfo".

setaf_black=`tput setaf 0`
setaf_blue=`tput setaf 1`
setaf_green=`tput setaf 2`
setaf_cyan=`tput setaf 3`
setaf_red=`tput setaf 4`
setaf_magenta=`tput setaf 5`
setaf_yellow=`tput setaf 6`
setaf_white=`tput setaf 7`

# For 88-colour rxvt-unicode these 8 colours are near-enough right.
# Try something like this to see the available colours:
#
# i=0
# while true
# do
# tput setaf $i
# echo "$i: Hello World"
# i=$(($i+1))
# done

# Define the colours to use.
# Set prompt_colour to the escape sequence for the colour to use for
# the prompt, and cmd_colours (an array) to the escape sequences for
# the colours to use for the commands, in turn.

declare -a cmd_colours

# A complicating factor is that we don't know whether this terminal
# has a white / light-coloured background or a black / dark-coloured
# background. This should influence our choice of colours.

# Here is a heuristic: virtual consoles have TERM=linux and are
# white-on-black, while X terminals and similar have TERM=xterm and
# are black-on-white.

case $TERM in
linux) background=dark ;;
*xterm*) background=light ;;
*) background=light ;;
esac

# Choose colours, based on the guessed background colour:

case $background in
dark) prompt_colour=$setaf_white
cmd_colours=($setaf_cyan $setaf_magenta $setaf_yellow) ;;
light) prompt_colour=$setaf_black
cmd_colours=($setaf_blue $setaf_green $setaf_red) ;;
esac

# This variable tracks which command colour is currently in use:

declare -i cmd_colour_index=-1

# This function increments cmd_colour_index modulo the number of
# command colours:

function next_colour() {
cmd_colour_index=$(( ($cmd_colour_index+1) % (${#cmd_colours[*]}) ))
}

# PROMPT_COMMAND is a bash builtin variable that names a command to
# run before each prompt. (This will override any existing use of
# this variable; how can multiple commands be chained together?)

PROMPT_COMMAND=next_colour

# This function returns the escape sequence for the current command
# colour, from the array defined above:

function cmd_colour() {
echo ${cmd_colours[$cmd_colour_index]}
}

# Define the prompt variables. For each one we encapsulate the
# current setting between a prefix and a suffix; the prefix sets the
# colour for the prompt and the suffix sets the colour for the
# command.

# \[ ... \] are used around non-printing characters and are needed so
# that Bash correctly calculates the screen position. Functions can
# be called using `...`, as long as the promptvars option is enabled:

shopt -s promptvars

prompt_prefix="\\[${prompt_colour}\\]"
prompt_suffix='\[`cmd_colour`\]'

PS1="${prompt_prefix}${PS1}${prompt_suffix}"
PS2="${prompt_prefix}${PS2}${prompt_suffix}"
PS3="${prompt_prefix}${PS3}${prompt_suffix}"
PS4="${prompt_prefix}${PS4}${prompt_suffix}"


Monday, January 22, 2007

 

remove the volumn icon on desktop

gconf-editor

apps->nautilus->desktop->volumes_visible
3:03 PM 我给你找找最简单的

sudo perl -pi -e 's/=.*/=GNOME;Applications;Settings/ if /^Categories/; s/^/#/ if /^NoDisplay/' /usr/share/applications/gconf-editor.desktop

Wednesday, January 10, 2007

 

new im tool for qq protocol

http://planet.time.net.my/TechnologyPark/evadeb/
Eva apt 存档 (非官方)
Eva 是一个可以与腾讯 QQ 互通的、基于 KDE 的自由软件即时通信工具。详情请参阅:
http://sourceforge.net/projects/evaq

本网站为 Eva 的 Debian apt 存档。目前只提供 Debian sid 包。

使用方法:
1. 将下面的行添加到您的 /etc/apt/sources.list 文件中:
deb http://planet.time.net.my/TechnologyPark/evadeb ./
2. 运行: apt-get update
3. 运行: apt-get install eva 或使用 aptitude 安装 "eva" 包

Tuesday, January 09, 2007

 

setup chinese input methon in en_US local

- fullfil the file as follow
kk:/home/kk# cat /etc/locale.gen
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8

- use locale-gen command to create a new locale

- install scim, scim-pinyin, imswitch.

- copy the documentation from /etc/X11/xinit/xinput.d/scim to /etc/X11/Xsession.d/90im-switch
don't forget use "export" in front of each line declare.


in ubuntu's fcitx:
sudo apt-get install im-switch

make sure the fcitx file in /etc/X11/xinit/xinput.d/, and the file have some declare, or even copy this declare into the /ect/X11/Xsession.d/90im-switch.
http://forum.ubuntu.org.cn/viewtopic.php?t=33401&highlight=fcitx
Force the IM modules can works in en locale.

"/usr/lib/gtk-2.0/2.4.0/immodules/im-xim.so"
"xim" "X Input Method" "gtk20" "/usr/share/locale" "en:ko:ja:th:zh"

This page is powered by Blogger. Isn't yours?