Tag Archive for 'vim'

vim tab 快捷键配置

1
2
3
4
map th :tabnext<CR>
map tl :tabprev<CR>
map tn :tabnew<CR>
map td :tabclose<CR>

Vim去掉utf-8的BOM

1
2
3
4
'去掉utf-8 BOM
:set nobomb
'保留utf-8 BOM
:set bomb

Efficient Editing With vim

我在这里发现了这篇关于VIM操作的文章,感觉不错,所以转载了过来。

This article has been translated into French by Geoffrey Bachelet. You can read the French version here: L’dition efficace avec vim.



“To me, vi is Zen.
To use vi is to practice zen.
Every command is a koan.
Profound to the user,
unintelligible to the uninitiated.
You discover truth every time you use it.”

[email protected]

This tutorial assumes a basic knowledge of vim — insert mode, command mode, loading and saving files, etc. It is intended to help vi novices develop their skills so that they can use vi efficiently.

In this tutorial, <C-X> means Ctrl-X — that is, hold down the Ctrl key and codess X. You can get help on most of the commands used here by typing :help command in vim, where command is what you need help on.

Moving efficiently

Stay out of insert mode

In general, you want to spend as little of your time in vim’s insert mode as possible, because in that mode it acts like a dumb editor. This is why most vim novices spend so much time in insert mode — it makes vim easy to use. But vim’s real power lies in command mode! You’ll find that the better you know vim, the less time you will spend in insert mode.

Use h, j, k, and l

The first step to efficient editing in vim is to wean yourself from the arrow keys. One of the the advantages of vim’s modal design is that you do not need to constantly move your hands back and forth between the arrow keys and the letter keys; when you are in command mode, the letters h, j, k and l correspond to the directions left, down, up, and right, respectively. It takes some practice to get used to, but you will notice the speed difference once you’re used to it.

When you are editing e-mail or other paragraph-formatted text, you might notice that the direction keys skip more lines than you expect. This is because your paragraphs appear as one long line to vim. Type g before h, j, k or l to move by screen lines instead of virtual lines.

Use motions to move the cursor in the current line

Most editors have only simple commands for moving the cursor (left, up, right, down, to beginning/end of line, etc). vim has very advanced commands for moving the cursor; these commands are referred to as motions. When the cursor moves from one point in the text to another, the text between the points (and including the points themselves) is considered to be “moved over.” (This will be important later.)

Continue reading ‘Efficient Editing With vim’

vim配置

vim大概是从大四的开始就一直在用的一些配置文件,好象是从gentoo的开发者站点上抓下来的吧 :)
[vim config file]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
set ai nocp digraph ek hid ru sc wmnu noet nosol si
set bs=2 fo=cqrt ls=2 shm=at ww=,h,l ts=4 sw=4
set com=s1:/*,mb:*,ex:*/,://,b:# syn=on filetype=on
set vi=%,'50,\"50,:50 lcs=tab:>-,trail:.,extends:>
set pt= shm=I tm=750 nomore modelines=5 hls!
syn on

ino gj
ino gk
nno gj
nno gk

nno :set hls!set hls?
nno :syn clear
nno :set nu!set nu?

if has("gui_running")
colo darkblue
set gfn=Bitstream\ Vera\ Sans\ Mono\ 8
else
colo ubuntu
" colo desert
" colo elflord
endif

Continue reading ‘vim配置’