Friday, October 22, 2010

VIM cook

http://www.oualline.com/vim-cook.html

Vim Cookbook

by Steve Oualline

This is the Vim cookbook page. It contains short recipes for doing many simple and not so simple things in Vim. You should already know the basics of Vim, however each command is explained in detail.

Each set of instructions is a complete package. Feel free to pick and choose what you need.

Contents

Character twiddling
Interactively replacing one word with another
Interactively replacing one word with another (command line method)
Replacing one word with another using one command
Moving Text (Vi style commands)
Moving Text (Visual mode)
Copying a block of text from one file to another
Copying a block of text from one file to another (Visual Method)
Sorting a section (Vi Style)
Sorting a section (Visual Method)
Dealing with Makefile and other SOB files
Formatting a text paragraph
Finding a procedure in a C program
Drawing comment boxes
Reading a man page
Removing carriage returns from MS-DOS file
Trimming the blanks off an end of line
Oops, I left the file write protected
Changing "Last, First" to "First Last"
How to edit all the files containing a given word
How to edit all the files containing a given word using the built-in grep


Character twiddling

If you type fast your fingers can easily get ahead of your mind. Frequently people transpose characters. For example the word "the" comes out "teh".

To swap two characters, for example "e" with "h", put the cursor on the cursor on the "e" and type xp.

The "x" command deletes a character (the "e") and the "p" pastes it after the cursor (which is now placed over the "h".)


Interactively replacing one word with another (n. method)

Suppose you want to replace every occurrence of the word "idiot" with the word "manager". But you want the chance to review each change before you do it.

Here's what you do:

1. 1G Go to the top of the document
2. /idiot<enter> Find the first occurrence of the word "idiot"
3. cwmanager Change the word (cw) to manager.
4. n Repeat the last search (find the next idiot.)
5. . Repeat the last edit (change one word to manager)
(If you do not want to change the word, skip this step.)

Repeat steps 4 and 5 until you have replaced all occurred.

The Virgin What!?

A church had just bought their first computer and were learning how to use it. The church secretary decided to set up a form letter to be used in a funeral service. Where the person's name was to be she put in the word "<name>". When a funeral occurred she would change this word to the actual name of the departed.

One day, there were two funerals, first for a lady named Mary, then later one for someone named Edna. So the secretary used global replace to change "<name>" to "Mary." So far so good. Next she generated the service for the second funeral by changing the word "Mary" to "Edna." That was a mistake

Imagine the Minister's surprise when he started reading the part containing the Apostle's Creed and saw, "Born of the Virgin Edna."


Interactively replacing one word with another (command line method)

Suppose you want to replace every occurrence of the word "idiot" with the word "manager". But you want the chance to review each change before you do it.

Execute the command:

:%s/\<idiot\>/manager/gc 

This command will make the change and pause after each change to give you a chance to confirm it. You can enter "y" to accept the change or "n" to not accept it.

The parts of this command are:

: Enter command mode
% Perform this command on all lines (% is a synomim for the first to last line.)
s The short form of the :substitute command.
/\<idiot\>/ This text specifies the text we are looking for wand want. The \< tells Vim to match a word start and the \> tells Vim to match the end of a word.
/manager/ The replacement text
gc The flags. These are
g
Global -- Change every occurance, not use the first one on each line
c
Confirm -- Ask before making each change

Replacing one word with another using one command

Suppose you want to replace every occurrence of the word "idiot" with the word "manager". No confirmation needed because all idiots are managers.

Use the command:

:%s/\<idiot\>/manager/g 

The parts of this command are:

: Enter command mode
% Perform this command on all lines (% is a synomim for the first to last line.)
s The short form of the :substitute command.
/\<idiot\>/ This text specifies the text we are looking for wand want. The \< tells Vim to match a word start and the \> tells Vim to match the end of a word.
/manager/ The replacement text
g Global flag -- This flag tells Vim to change every occurance on the line, not use the first one.

Moving Text (Vi style commands)

Suppose you want to move a paragraphs from the top of the document to the bottom. There are several ways of doing this. In this example, we do it using Vi style command. In the next section Moving Text (Visual mode) we do it using using the Vim visual commands.

To do the move the commands:

Command Explaination
1.   Move the cursor to the top of the paragraph you want to move.
2. ma Place a mark named "a" at this location. (Vim will give you no indication that this command has been executed. In other words, the screen will not change.)
3.   Move the cursor to the bottom of the paragraph to be moved.
4. d'a Delete to mark "a". This puts the deleted text in a cut buffer.
5.   Move the cursor to line where the text is to go. The paragraph will be placed after this one.
6. p Paste the text in below the cursor.

Moving Text (Visual Method)

Suppose you want to move a paragraphs from the top of the document to the bottom. There are several ways of doing this. In this example, we do it using the Vim Visual mode. In the previous section Moving Text (old method) we do it using using the Vi style commands.

To do the move the commands:

Command Explaination
1.   Move the cursor to the top of the paragraph you want to move.
2. v Start visual mode. (If you want to move only full lines, use the V command which starts visual line mode.
3.   Move the cursor to the bottom of the paragraph to be moved. The text to be moved will be hightlighted.
4. d Perform a visual delete. In other words delete the highlighted text.
5.   Move the cursor to line where the text is to go. The paragraph will be placed after this one.
6. p Paste the text in below the cursor.

Copying a block of text from one file to another (Vi Style)

There is more than one way to copy text between files. In this section we use the more triditionally Vi commands. In the next section Copying using visual mode, we perform the same operations using the Visual mode.

To copy a block of text between files execute the commands:

Command Explaination
1.   Edit the file containing the text you want to copy.
2.   Go to the top line to be copied.
3. ma Mark this line as mark "a".
4.   Go to the bottom line to be copied
5. y'a Yank (y) the text from the current cursor location to the mark "a" ('a)
6. :split second-file Open another window containing the second file. (This the file in which the text is to be inserted.)
7.   Go to the line where the insert is to occur. The text will be place after this line.
8. p Put the text after the cursor.

Copying a block of text from one file to another (Visual Method)

There is more than one way to copy text between files. In this section we use the newer visual mode commands. See the previous section for the older Vi Style of doing things.

To copy a block of text between files execute the commands:

Command Explaination
1.   Edit the file containing the text to be copied.
2.   Go to the top line to be copied.
3. v Start visual mode. If you want to copy a block of full lines, use V to go start Visual Line Mode
4.   Go to the bottom line to be copied. The text to be copied will be hightlighted.
5. y Yank (y) the text.
6. :split second-file Open another window containing the second file. (This the file in which the text is to be inserted.)
7.   Go to the line where the insert is to occur. The text will be place after this line.
8. p Put the text after the cursor.

Sorting a section (Vi Style)

Frequently you will be editing a file with a list of names in it. For example, a list of object files that make up a program.

For example:

	version.o  	 	pch.o		 	getopt.o 	 	util.o		 	getopt1.o	 	inp.o		 	patch.o		 	backupfile.o 

This list would be nice in alphabetical order. Or at least ASCII order. To alphabetize this list execute the commands:

Command Explaination
1.   Move the cursor to the first line to be sorted.
2. ma Mark the first line as mark a.
3.   Move to the bottom of the text to be sorted.
4. !'asort The ! command tells Vim to run the text through UNIX command. The 'a tell the editor that the text to be worked on starts at the current line and ends at mark a. The command that the text is to go through is sort.

The result looks like:

	backupfile.o 	getopt.o 	 	getopt1.o	 	inp.o	 	patch.o		 	pch.o		 	util.o		 	version.o  	 

Warning

In actual practice what you in most Makefiles (file that are used by UNIX to control compilation) looks more like:

OBJS = \         version.o       \         pch.o           \         getopt.o        \         util.o          \         getopt1.o       \         inp.o           \         patch.o         \         backupfile.o 

Notice that the backslash (\) is used to indicate a continuation line. After sorting this looks like:

OBJS = \         backupfile.o         getopt.o        \         getopt1.o       \         inp.o           \         patch.o         \         pch.o           \         util.o          \         version.o       \ 

The names are in order, but the backslashes are wrong. Don't forget to fix them using normal editing before continuing.

OBJS = \         backupfile.o    \         getopt.o        \         getopt1.o       \         inp.o           \         patch.o         \         pch.o           \         util.o          \         version.o 

Sorting a section (Visual Method)

Frequently you will be editing a file with a list of names in it. For example, a list of object files that make up a program.

For example:

	version.o  	 	pch.o		 	getopt.o 	 	util.o		 	getopt1.o	 	inp.o		 	patch.o		 	backupfile.o 

This list would be nice in alphabetical order. Or at least ASCII order. To alphabetize this list execute the commands:

Command Explaination
1.
Move the cursor to the first line to be sorted.
2. V Enter visual line mode
3.
Move to the bottom of the text to be sorted.
4. !sort The ! command tells Vim to run the hightlighted text through UNIX command. The command that the text is to go through is sort.

Warning

Check out the sort warning section for a short description of the problems that can result from using this command.

Dealing with Makefile and other SOB files

One problem with the file format used by the UNIX make command is that it's extremely fussy.

For example, the following is correct:

        prog: prog.c                 cc -g -o prog prog.c 

The following is not:

        prog: prog.c                 cc -g -o prog prog.c 

At first glance you might think that these two are exactly. But look closer. The "cc" line of the first one begins with a tab. The second one begins with eight spaces. (You can't tell the difference between a space and a tab when it's printed on the screen! You need a better video card.)

So how are you supposed to tell them apart especially when one the screen (or the printed page) they look exactly the same.

The answer is you can't. You might think that's a bit unfair. Especially when make works on the first one but not the second. But who every said UNIX was fair.

Fortunately Vim has a mode that tells you exactly what's in your file. Executing the command

	:set list 
puts you into this mode. When the display is set into "list mode" all characters print. Tabs show up as "^I" and the end of line shows up as $. So in list mode, our two examples look like:
        prog: prog.c$         ^Icc -g -o prog prog.c$ 

and

        prog: prog.c$                 cc -g -o prog prog.c$ 

From this it's easy to see which line has the tab.


Formatting a text paragraph

The Vim editor is not a word processor. Boy is it not a word processor. There are a couple of things you can do to make things better for you when editing text.

Word processors automatically wrap when you type a line that's longer than the margins. The Vim editor lets make a line as long as you want. By executing the command:

        :set wrapmargin=70 

you can tell Vim to automatically break lines when the run longer than 70 characters. (You can adjust this number to whatever line length you want.)

This makes entering text much easier. It doesn't solve the problem of editing. If you enter a paragraph and then decide to delete half the words on the first line, Vim will not reformat the text.

You can force a reformat of a paragraph by executing the commands:

Command Explaination
1.   Move to the top of the paragraph.
2. gq} The "!" command tells Vim to pipe a section of text through a filter. The } tells Vim that the section of text for the pipe command is a single paragraph.
3. fmt -70 The UNIX command fmt is a primitive formatter. It performs word-wrapping well enough for text documentation. The -70 tells fmt to format lines for 70 characters per line.

Finding a procedure in a C program

The Vim program was designed by programmers for programmers. You can use it to locate procedures within a set of C or C++ program files.

But first you must generate a table of contest file called a "tags" file. (This file has been given the obvious name tags.) The ctags command generates this table of contents files.

To generate a table of contents of all the C program files in your current working directory, use the command:

        $ ctags *.c 

For C++ use the command:

        $ ctags *.cpp 

If you use an extension other than .cpp for your C++ files, use it instead of .cpp.

Once this file is generated, you tell Vim that you want edit a procedure, and it will find the file containing that procedure and position you there. For example if you want to edit the procedure write_file use the command:

        $ vim -t write_file 

Now suppose as you are looking at the write_file procedure that it calls setup_data and you need to look at that procedure. To jump to that function, position the cursor at the beginning of the word setup_data and press Ctrl+]. This tells Vim to jump to the definition of this procedure. This repositioning will occur even if Vim has to change files to do so.

Note:

If you've edited the current file and not saved it, Vim will issue a warning and ignore the Ctrl+] command.

Drawing comment boxes

I like to put a big comment box at the top of each of my procedures. For example:

	/******************************************************* 	 * Program -- Solve it -- Solves the worlds problems.  * 	 *     All of them.  At once.  This will be a great    * 	 *   program when I finish it.                         * 	 *******************************************************/ 

Drawing these boxes like this is tedious at best. But Vim has a nice feature called abbreviations that makes things easier.

First, you need to create a Vim initialization file called ~/.vimrc. (At first this may look like a ex initialization file. It is. The Vim command is actually a mode of the ex editor.)

The ~/.vimrc file need to contain the lines:

        :ab #b /************************************************         :ab #e ************************************************/ 

These command define a set of Vim abbreviations. What's a Vim abbreviation? Its a word that stands for another word. When Vim see the abbreviation, it will expand it to the full word. In this case we've defined an abbreviation called #b that expands to the beginning line of a comment box. The #e abbreviation does the same thing.

So to create a comment box enter #b<enter>. The screen looks like:

        /************************************************ 
Enter the comments, including the beginning and ending "*" characters. Finally end the comment by typing #e<enter>. This causes the ending comment to be entered.

Note:

This page was written in Vim. So how did we enter the #b and #e? Easy, we typed in #bb and the deleted a character. (We couldn't enter #b or it would have been expanded.)

Some other useful commands that programmer may want to put in their ~/.exrc include:

	:set autoindent 	:set autowrite 	:ab #d #define 	:ab #i #include 	:ab #b /************************************************ 	:ab #e ************************************************/ 	:ab #l /*----------------------------------------------*/ 	:set sw=4 

The autoindent setting causes Vim to indent new lines by a similar amount to the one next to them. This is very useful for entering programs. The autowrite setting tells Vim to write the old file out when switching from one file to another.

The abbreviations #d, #i, and #l, define useful terms for programmers.

Finally, the command set sw=4 sets the shift width (the number of characters text is moved sideways for the shift command (<< and >>)).

This is very useful if you use a 4 space indentation for your C or C++ programs. (Studies at Rice University have shown this to be the best indentation size.)


Reading a man page

You can use the Vim editor to browse through text files. One of the most useful set of files to browse through is the man pages. To do this we assemble a pipeline of three command.

The first is man which gets the page. The next one, ul turns the underline and bold escape codes into something readable, and finally we use Vim to broswe the file.

So our command is:

$ man subject | ul -i | vim - 

The man page will be generated and then displayed in the Vim window. You can now use your normal editing commands to browse the files.


Removing carriage returns from MS-DOS file

If you ever try to edit a MS-DOS file, you'll notice that each line ends with a ^M character. This is caused by the funny way that MS-DOS treats the end-of-line. (For some background on this problem take a look at The EOL Story.

To remove the ^M characters from a MS-DOS file, enter the command:

	:1,$s/{Ctrl+V}{Ctrl+M}//{Enter} 
This command starts with a colon (:) to tell Vim to enter ex mode. All ex start with a line number range, in this case its from the first line (1) to the last ($). The slash indicates the start of the "from text". The {Ctrl+V} tells Vim to treat the next character as a regular character even if it's a special one. The next character is {Ctrl+M}. (This would be treated as {Enter} without the {Ctrl+V}.) The next slash ends the "from text". What follows is the "to text" enclosed by slashes. In this case it's nothing (//).

Trimming the blanks off an end of line

Some people find spaces and tabs at the end of a line useless, wasteful, and ugly. To remove whitespace at the end of every line, execute the command:

	:1,$s/[ <tab>]*$// 

The colon (:) tells Vim to enter ex command mode. All ex commands start with a line range, in this case, the entire file (line 1 to the last line: $).

The first set of slashes enclose the "from text". The square brackets indicate that either character can be a match. So [ <tab>] matches either space or tab. The star (*) means that the previous character specification (space or tab) can be repeated any of number times. The dollar ($ indicates an end of line.

So [ <tab>]*$ tells Vim to look for any number of spaces or tabs followed by an end of line.

These are then replaced by the text in the next set of slashes. This text is nothing, so the spaces and tabs are effectively removed.


Oops, I left the file write protected

Say your editing a file and you've made a lot of changes. This is a very important file and to preserve it from any casual changes, you've write protected it, even against yourself.

The Vim editor allows you to edit a write protected file with little or no warning. The only trouble is that when you try to exit using "ZZ" you get the error:

    file.txt	File is read only 

and Vim doesn't exit.

So what can you do? You don't want to throw away all those changes, but you need to get out of Vim so you can turn on write permission.

The trick is to execute the :shell command. This command takes you out of Vim by starting a command processor (shell) running under Vim

You can then write enable the file:

  	$ chmod u+w file.txt 
and get out of the shell, returning to Vim
	$ exit 

Finally you need to force Vim to write the file using the command:

	:w! 
(It still thinks the file is write protected so we need to use the force option (!) to convince it to try writing.)

Note:

It is a good idea to only spend as short a time as possible in a command processor started by the :shell command. That's because it's easy to forget that you're running under Vim. It's possible to start a shell, that starts Vim, that starts a shell, that starts Vim, that .... Using this method you can easily consume a lot of resources and generate a lot of confusion.

By keeping your :shell sessions short you can avoid lots of trouble.


Changing "Last, First" to "First Last"

You have a list of names in the form:

	Last, First 

How to you change them to:

	First Last 
It can be done with one command:
    :1,$s/\([^,]*\), \(.*$\)/\2 \1/ 
The colon (:) tells Vim that this is an ex style command.

The line range for this command is the whole file as indicated by the range 1,$.

The s (substitute) tells Vim to do a string substitution.

The old text is a complex regular expression. The \( ... \) delimiters are used to inform the editor that the text that matches the regular expression side is to be treated special.

The text in the first \( ... \) is assigned to \1 in the replacement text. The second set of text inside \( ... \) is assigned \2 and so on.

In this case the first regular expression is any bunch of characters that does not include a comma. The [^,] means anything but a comma, the * means a bunch (zero or more characters).

The second expression matches anything: .* up to the end of line: $.

The result of this substitution is that the first word on the line is assigned to \1 and the second to \2. These values are used in the end of the command to reverse the word.

The figure below shows the relationship between the \( \) enclosed strings and the \1, \2 markers.

	:1,$s/\([^,]*\), \(.*$\)/\2 \1/ 	      ^^     ^^  ^^   ^^^ ^  ^             	      ||     ||  ||   ||| |  +-----  String matched by  	      ||     ||  ||   ||| |          first \( \) 	      ||     ||  ||   ||| +--------- String matched by 	      ||     ||  ||   |||            second \( \) 	      ||     ||  ||   ||+----------- Slash separating  	      ||     ||  ||   ||             old/new strings 	      ||     ||  ++---++------------ Second \( \)  	      ++-----++--------------------- First \( \) 

The next figure breaks out the various parts of the regular expressions used in this example.

	:1,$s/\([^,]*\), \(.*$\)/\2 \1/ 		^^^^^  ^^  ^^^ 		|||||  ||  ||+--- The end of the line 		|||||  ||  |+---- Repeated 0 or more time 		|||||  ||  +----- Any character 		|||||  ||  +++--- Any character, repeated, 		|||||  ||             followed by EOL 		|||||  |+-------- The character space 		|||||  +--------- The character comma 		||||+------------ Repeated 0 or more times 		|||+------------- Closes the [] expression 		||+-------------- The character comma 		|+--------------- Match anything except the 		|                 next character 		+---------------- Starts a set of matches 		++++------------- Match anything but comma 		    +------------ Repeated 0 or more times 		       +--------- Followed by comma 

How to edit all the files containing a given word

This involves the fgrep as well as the special shell character backtick (`).

To edit all the C program files that contain the word indentation_level execute the command:

    $ vim `fgrep -l indentation_level *.c` 

The fgrep -l indentation_level *.c searches all the files ending with .c for the word and lists them out.

Since this command is enclosed in backtick (`) characters the results of the command (a list of files) takes the place of the command on the command line.

The Vim editor is then run on these files. The commands :n{Enter} and :rew{Enter} can then be used to browse through the files.

How to edit all the files containing a given word using the built-in grep

Start Vim.

Execute the command:

    :grep >word< >file-list< 

This finds the first location of word in the given files and positions the cursor on that line. You can use the command :cn to find the next occurance.

THC/DOC/ORC/BAF

THC:Terminal Handling Charges码头操作费  DOC:Document charges文件费  ORC:Original receipt charge原场地码头附加费  BAF:BUNKER ADJUSTMENT FACTORY油价调整指数附加费 

Friday, October 15, 2010

铁矿石进口权企业名单 2009

1 上海宝钢集团
2 鞍山钢铁集团公司
3 武汉钢铁(集团)公司
4 首钢总公司
5 马鞍山钢铁股份有限公司
6 唐山钢铁集团有限责任公司
7 江苏沙钢集团有限公司
8 湖南华菱钢铁集团有限责任公司
9 济南钢铁集团总公司
10 邯郸钢铁集团有限责任公司
11 莱芜钢铁集团有限公司
12 本溪钢铁(集团)有限责任公司
13 包头钢铁(集团)有限责任公司
14 攀枝花钢铁(集团)公司
15 安阳钢铁集团有限责任公司
16 南京钢铁股份有限公司
17 唐山国丰钢铁有限公司
18 广东韶关钢铁集团有限公司
19 天津铁厂
20 河北津西钢铁股份有限公司
21 建龙钢铁控股有限公司
22 宣化钢铁集团有限责任公司
23 新余钢铁股份有限公司
24 广西柳州钢铁(集团)公司
25 太原钢铁(集团)有限公司
26 广州钢铁企业集团有限公司
27 杭州钢铁(集团)公司
28 昆明钢铁集团有限责任公司
29 重庆钢铁(集团)有限责任公司
30 福建三钢(集团)有限责任公司
31 通化钢铁集团有限责任公司
32 山西海鑫钢铁有限公司
33 萍乡钢铁有限责任公司
34 酒泉钢铁(集团)有限责任公司
35 青岛钢铁控股集团有限责任公司
36 邢台钢铁有限公司
37 承德钢铁集团有限责任公司
38 石家庄钢铁有限责任公司
39 四川川威钢铁集团有限公司
40 水城钢铁(集团)有限责任公司
41 南昌钢铁有限责任公司
42 天津天钢集团有限公司
43 江阴兴澄特种钢铁有限公司
44 湖北新冶钢有限公司
45 唐山世纪晨晖钢铁制品有限公司(半钢)
46 长治钢铁(集团)有限公司
47 抚顺新抚钢有限责任公司
48 江苏永钢集团有限公司
49 河南济源钢铁(集团)有限公司
50 陕西龙门钢铁(集团)有限责任公司
51 河北敬业钢铁有限公司
52 新兴铸管股份有限公司
53 天津钢管有限责任公司
54 江苏苏钢集团有限公司
55 日照钢铁控制股集团有限公司
56 山东泰山钢铁有限公司
57 河北栾河实业有限公司
58 安阳永兴钢铁有限责任公司
59 湖南冷水江钢铁总厂
60 江苏雪丰钢铁股份公司
61 张钢制铁铸管有限公司
62 新疆八一钢铁集团有限责任公司
63 凌源钢铁集团有限责任公司
64 华西钢铁公司
65 德龙钢铁有限公司
66 西林钢铁集团有限公司
67 河北普阳钢铁公司
68 中天钢铁集团有限责任公司
69 山西宇晋钢铁有限公司
70 河北文丰钢铁有限公司
71 中化国际(控股)股份有限公司
72 中国通信建设总公司
73 上海上实国际贸易(集团)有限公司
74 福建三安集团有限公司
75 中建材集团进出口公司
76 中化物产股份有限公司
77 四川川投国际贸易有限公司
78 瑞钢联集团有限公司
79 中国瑞联实业集团有限公司
80 中达国际经贸集团有限责任公司
81 浙江物产集团公司
82 江苏省对外经贸股份有限公司
83 延边天池工贸有限公司
84 上海市五金矿产进出口公司
85 唐山市福翼物资有限公司
86 安徽省技术进出口股份有限公司
87 山东九羊实业股份有限公司
88 秦皇岛太行贸易有限公司
89 中国五矿集团公司
90 中国中信集团公司
91 中基宁波对外贸易股份有限公司
92 厦门国贸集团股份有限公司
93 上海久茂对外贸易有限公司
94 大连东展集团有限公司
95 新疆阿拉山口口岸工贸股份有限公司
96 天津中联进出口贸易有限公司
97 青岛新兴东方进出口总公司
98 中国外运山东有限公司
99 上海埃力生(集团)有限公司
100 江苏省华贸进出口有限公司
101 中储发展股份有限公司
102 上海�隆进出口有限公司
103 山西省冶金物资总公司
104 青岛华青进出口有限公司
105 俊安(天津)实业有限公司
106 日照中瑞物产有限公司
107 宁波百丰选矿有限公司
108 南金兆集团有限公司
109 陕西北冶人和贸易有限公司
110 中国中钢集团公司
111 深圳市南天辉进出口有限公司
112 山东省国际贸易集团中心
113 山东万宝贸易有限公司
114 山东华信工贸有限公司
115 山西大晋国际(集团)股份有限公司
116 北台钢铁(集团)进出口有限责任公司
117 沈阳东方钢铁有限公司
118 山西三联正丰国际贸易有限公司

Thursday, October 14, 2010

CIF

什么是CIF?http://baike.baidu.com/lemma-php/dispose/view.php/64850.htm

【到岸价格】
注意了CIF不能称之为到岸价,这是不准确的。

长期以来,人们习惯于把国际贸易中的FOB价格条件称为离岸价格,从而也把价格术语中包含运费与保险费的CIF说成到岸价。甚至在一些正规媒体的文章中也不时出现这样的说法。如在谈到中国大豆的国际市场竞争力时,经常有报道说,中国大豆的离岸价(FOB)高于国外进口转基因大豆的"到岸价"(CIF)等等。

FOB价格说成离岸价格是符合其含义的形象说法,因为FOB价格包含的是出口产品在越过船舷之前的所有成本与费用,风险也在装运港的船舷由卖方转移给买方,但把CIF价说成是到岸价格说成就是一种不科学的说法了。人们之所以误称CIF为"到岸价"是由于从表面上看CIF价格术语的确包含至目的港的运费和保险费,人们只是单纯地从价格构成来为其命名。

国际贸易中真正意义上的到岸价应该是DES,而不是CIF,从交货地点来看,按《国际贸易术语解释通则》以及其他两个有关贸易术语的国际惯例解释。CIF价格条件下的卖方叫过地点不是目的港,而是装运港。它是一种典型的象征性交货价格术语。卖方只要按期在约定地点完成装运,并向卖方提交合同约定的提单等有关单据就算完成了交货义务。至于货物何时抵达目的港,除非卖方在合同中做了明确的承诺,卖方不对货物的抵港时间承担任何责任。而真正意义上的到岸价格DES价格术语的含义是卖方要在规定的时间和地点将符合合同规定的货物提交买方,不能以交单代替交货。

CIF不是到岸价还因为CIF的风险转移界限也是装运方船舷而不是目的港。例如,采用CIF价格术语成交的合同,如果载货船舶在尚未驶离装运港就触礁沉没了,买方是无法向卖方提交索赔的,理由是越过船舷后的风险已转移至买方,买方只能依据保险合同合同向保险公司进行索赔。这说明卖方对于风险并不负责至目的港,即到岸的价格术语是DES。在此术语下,风险在货物被置于买方实际控制之下时转移,此前的风险完全由卖方承担。如上述案例中,如果使用的DES而不是CIF,买方就可以在货物没有抵港之前不必考虑也误需承担任何风险,这才符合到岸价格的真正含义。

另外,在CIF的条件下,由装运港至目的港的保险属代办性质,卖方只需按规定会惯例承担正常保险费用。如果没有特别规定,卖方只需投买最低的保险险别就算是完成了CIF的保险义务;而在真正的到岸价DES条件下,卖方是为自己的利益投买保险的,他要根据自己货物的情况来确定投保金额与保险险别,以及考虑是否加保各种附加险而支付保险费。

再者,CIF术语中的F 是指运费freight,按《国际贸易术语解释通则规定,CIF合同中卖方的义务是按照通常的条件及惯驶的航线,负责租船或订舱并支付运费。但这里所说的运费只是正常的运费,在运输中载货船舶可能遇到恶劣天气,船上的机器可能出现故障,需要避风或修理,也可能由于转船或绕汉等发生的运费称为不正常运费。在CIF条件下,不正常运费均应由买方承担。如国内某公司以CIF纽约价格条件向美国出口某商品,在投保一切险的基础上加保了战争险和罢工险。在载货船舶尚未抵达纽约港前,船方获悉纽约港正在罢工,不能靠岸卸货,于是便将货物卸在纽约港附近的一个港口。一个月后,纽约港罢工结束,货物又由该港转运到纽约港,但增加了1500美元的运费,对这笔额外运费的负担问题各方之间产生了争议,对保险公司来说,虽然接受了罢工险的投保,但因罢工改港卸货多增加的运费属于间接损失,所以保险公司拒绝赔偿,而承运人依据提单的免责条款也可以不负责任。卖方在CIF价格条件下负担的是正常运费,在货物越过船舷后风险与费用就都转移出去了,不必再考虑货到目的港前的任何偶然事件所引起的额外运费。争议的最终结果是1500美元的额外运费只能由买方自己承担了。由此看来,船舶在没有到岸时,发生的运费仍需买方承担。所以,没有理由称CIF为到岸价。

【离岸价格】free on board

以货物装上运载工具为条件的价格。又称装运港船上交货价格。根据国际商会修订公布的《1980年贸易术语解释的国际通则》,卖方必须做到以下几点:①负责在合同规定的装运港和装运期内,按港口惯例将货物装上买方指定的船上,并及时向买方发出装船通知。②负担货物越过船舷以前的各项费用和风险。③办理出口手续,并提供合同规定的各项单证。买方必须做到以下几点:①负责租船订舱和支付运费,并将船名及装货日期通知卖方。②负担货物自越过船舷时起的一切费用和风险。③接受卖方提供的有关单证,并支付货款。美国、加拿大等一些国家在国际贸易中,对离岸价格的解释与国际商会有所不同。由于各国的港口对离岸价格有不同的解释和习惯,因此凡大宗货物按离岸价格条件成交时,买卖双方在装货费用由谁负担等问题上一定要有明确规定,分清责任,防止误解。在一定条件下,进口采用离岸价格对进口国有一定的好处。在离岸价格条件下,进口国可选择本国的船舶运输,向本国保险公司投保,这样可避免肥水外流,商业风险相对较小。

外贸交易术语



买卖双方所承担的运输、保险责任互相对应、即 FCA 和 FOB 一样,由买方办理运输, CPT 和 CFR 一样,由卖方办理运输,而 CPT 和 CFR 一样,由卖方承担办理运输和保险的责任。

  CPT 、 FCA 、 CIP 与传统的 FOB 、 CFR 、 CIF 相比较。有以下三个共同点:

  (1)都是象征性交货,相应的买卖合同为装运合同;

  (2)均由出口方负责出口报关,进口方负责进口报关;

  (3)买卖双方所承担的运输、保险责任互相对应、即 FCA 和 FOB 一样,由买方办理运输, CPT 和 CFR 一样,由卖方办理运输,而 CPT 和 CFR 一样,由卖方承担办理运输和保险的责任。

  由此而产生的操作注意事项,也是相类似的。

  这两类贸易 术语 的主要不同点在于:

  (1)适合的运输方式不同、CPT、 FCA 、 CIP 适合于各种运输方式,而 FOB 、CFR、ClF,只适合于 海运 和内河运输;

  (2)风险点不同。CPT、FCA、 CIP 方式中,买卖双方风险和费用的责任划分以“货交承运人”为界,而传统的贸易 术语 则以“船舷”为界;

  (3)装卸费用负担不同。CPT、FCA、CIP由承运人负责装卸,因而不存在需要使用贸易 术语 变形的问题

  (4)运输单据性质不同。 海运 提单具有物权凭证的性质,而航空运单和铁路运单等,不具有这一性质。

  所以,除了风险点不同之外,可以把CPT、FCA、CIP看成是 FOB、CFR、 CIF 方式从 海运 向各种运输方式的延伸。

常用外贸报价方式

介绍几种常见的外贸报价方式:EXW,FOB,CIF和CFR.
外贸报价方式一、工厂交货价(EXW=Ex Works):
交货地点:出口国工厂或仓库;
运  输:买方负责;
保  险:买方负责;
出口手续:买方负责;
进口手续:买方负责;
风险转移:交货地;
所有权转移:随买卖转移;
外贸报价方式二、离岸价(FOB=Free on Borad):
交货地点:装运港;
运  输:买方负责;
保  险:买方负责;
出口手续:卖方负责;
进口手续:买方负责;
风险转移:装运港船舷;
所有权转移:随交单转移;
外贸报价方式三、到岸价(成本 运费 保险费,CIF=Cost Insurance Freight):
交货地点:装运港;
运  输:卖方负责;
保  险:卖方负责;
出口手续:卖方负责;
进口手续:卖方负责;
风险转移:装运港船舷;
所有权转移:随交单转移;
外贸报价方式四、成本加运费(CFR=Cost Freight):
交货地点:装运港;
运  输:卖方负责;
保  险:买方负责;
出口手续:卖方负责;
进口手续:买方负责;
风险转移:装运港船舷;
所有权转移:随交单转移;
FOB、CIF、CFR这三种外贸报价方式的共同点:
01,卖方负责装货并充分通知,买方负责接货;
02,卖方办理出口手续,提供证件,买方办理进口手续,提供证件;
03,卖方交单,买方受单、付款;
04,装运港交货,风险、费用划分一致,以船舷为界;
05,交货性质相同,都是凭单交货、凭单付款;
06,都适合于海洋运输和内河运输;
FOB、CIF、CFR这三种外贸报价方式间的不同点:
01,FOB:买方负责租船订舱、到付运费;办理保险、支付保险;
02,CIF: 卖方负责租船订舱、预付运费;办理保险、支付保险;
03,CFR:卖方负责租船订舱、预付运费;买方负责办理保险、支付保险;

Wednesday, October 13, 2010

so low ?

at least 2.10 to keep population right ?

in reference to:

"According to latest 2010 statistics, Singapore’s resident total fertility rate (TFR) reached a level of 1.22 in 2009. The Chinese TFR was (1.08), followed by Indians (1.14) and Malays (1.82). Malay fertility-rate is ~70% higher than Chinese and Indians.[85]"
- Singapore - Wikipedia, the free encyclopedia (view on Google Sidewiki)

List of offshore financial center

http://en.wikipedia.org/wiki/List_of_offshore_financial_centres
---
Singapore is also one of them ...

in reference to:

"The following are designated as offshore financial centres by the IMF[1], the FSF and recently Ministry of Finance (Brazil)[2]:"
- List of offshore financial centres - Wikipedia, the free encyclopedia (view on Google Sidewiki)

Tax around the world

http://en.wikipedia.org/wiki/Tax_rates_around_the_world

in reference to:

"Singapore 17%[30] 3.5%-20% 7% (GST) Income tax in Singapore Goods and Services Tax (Singapore)"
- Tax rates around the world - Wikipedia, the free encyclopedia (view on Google Sidewiki)

Sunday, October 03, 2010

Corporate account in singapore


UOB 6226-6121
Initial $1K
Min $10k
Fee $15 / mth under 10K
Internet Access - free if using "pro" package
Transfer fees: In bank free, out of bank (in sing) $2 (giro?), wire min $30
Checks: 30 / mth, .50 after
Min period: 6 mos.
Security Device: $20 each (1 needed, so basically $20 set up fee)

DBS 6222-2200
Initial $3K
Balance Min $10k
Fee $15 / mth under $10K
Internet Access $30 setup + $30 / mth
Transfer fees: In bank free, out of bank (in sing) Giro .20, wire min $18
Checks: 30 / mth, .40 after
Min period: 6 mos.
Security Device: Free for 2, 2 required from internet


OCBC 6538-1111
Initial $5K
Min $10k
Fee $15 / mth under $10K
Internet Access - free
Transfer fees: ocbc to ocbc free, GIRO .20 /transcaction, wire min $30
Checks: 30 / mth, .50 after
Min period: 6 mos.
Security Device: Free for 1 (2 users needed), 2nd is $20


Standard Chartered 6743-3000
essential account
Initial $3K
Min - none
Internet Access - free
Transfer fees: internal free, giro free, meps $20, wire min $30
Checks: .30 check
Min period: 6 mos.
Security Device: Free for 1 (1 needed)