vimrc & vim short key 1

来源:互联网 发布:中国历年老年人口数据 编辑:程序博客网 时间:2024/05/06 14:31

 

nice job : http://www.360doc.com/content/10/1128/15/4807202_73143894.shtml

 

vim short keys


1. w e b 在单词之间移动,使用 */# 搜索当前词,使用 . 重复上一次的操作,使用 >> << 进行缩进
2. {和}在空行之间移动,[]/][移动到 上一个/下一个 函数尾,移动到山一个函数尾部,%在函数的开始、结束来回跳,[{/]}跳到函数的头部/尾部
3. mark: ma mb用来在一个文件中打标记,mA mB 在不同文件之间打标记
   jump: 'a跳转到当前文件的a标记处,''跳转到前一个标记处,'A跳转到第一个文件、'B跳转到第二个文件
4. gd 用来查找变量的局部定义,但是有些时候不太好用;gD用来查找变量的全局定义
5. 导入本包中的库#include "ctrl+x ctrl+f;自动补齐 ctrl+p
6. vim file1 file2,先显示file1,而后:n显示file2,再显示file1 :e#
7. 快速修复编译错误
   a.  提供makefile;
   a'. :set makeprg=cc/ -Wall/ myp.c/ -o/ myp
   b.  :make
   c.  使用cn、cN、3cn、4cN在不同错误之间移动,进行修改
8. 使用 :gf 打开文件,e.g.头文件。使用 :g/someword/d。如果日志一行很长可以j :nmap j gj、:nmap k gk来查看

 

http://blogold.chinaunix.net/u/11786/showart_1888394.html

 

.vimrc: modify http://www.ngolde.de

 

" expand tabs
set expandtab

" show the laststatus line always
set laststatus=2
" give cursor position
set ruler
" number of undos
set undolevels=2000
" jump to the word you search during you type
set incsearch
set ignorecase
" highligth search results
set hlsearch
" continue searching at top when hitting bottom
"set wrapscan

" do i have a fast terminal?
set nottyfast
" make no backups
set nobackup
" we use a dark background_
set background=dark
" fuck the beeps
set noerrorbells
" for hidden buffers
set hidden
set smartindent

"always show the command
set showcmd

set smarttab
" show all changes
set report=0
" highlight current line
set cursorline
" Highlight matching parens
set matchpairs=(:),[:],{:},<:>
" no the terminal is not always fast
set nottyfast
" use autoindent
set autoindent

" how many spaces for indenting
set shiftwidth=3
" tab width_
set tabstop=3

" fancy menu
set wildmenu
" display unprintable characters
set list!


" display utf-8 chars
set encoding=utf-8
" enumerate Lines
set nu
" substitude tabs with » and trailing spaces with ·
"set list listchars=tab:>·,trail:·,eol:$
set list listchars=tab:>·,trail:<c2><b7>
" after 75 characters write a swap file
set uc=75

" do not behave like vi, vi is dead_
set nocompatible
" use color sheme
" color ron_
" color pablo
" use the modelines commands
set modeline
" use 3 lines for modelines
set modelines=3
" use , as mapleader variable
let mapleader=","

" Use brighter colors if your xterm has a dark background.
if &term =~ "xterm"
  set background=dark
endif

"========================
" Syntaxhiglighting
"========================
let color = "true"
syntax on

if version>=700
  set pumheight=7
endif

" comment types_
set comments=b:#,:%,fb:-,n:),n:> fo=cqrt


iab packet paket
iab Packet Paket
iab felher fehler
iab paranoit paranoid
iab Standart Standard
iab herran hera
iab ider oder
iab alos also
iab charcter character
iab examlpe example
iab nciht nicht
iab Netwokr     Network
iab Srever      Server
iab Standart    Standard
iab standart    standard
iab SIe         Sie
iab ICh         Ich
iab cih         ich
iab shc         sch
iab amchen      machen
iab amche       mache
iab Linx        Linux

" give current date
iab DATE <C-R>=strftime("%a %b %d %T %Z %Y")<CR>




" before quit vim, save editing session
" Tell vim to remember certain things when we exit
"  '10  :  marks will be remembered for up to 10 previously edited files
"  "100 :  will save up to 100 lines for each register
"  :20  :  up to 20 lines of command-line history will be remembered
"  %    :  saves and restores the buffer list
"  n... :  where to save the viminfo files
set viminfo='10,/"100,:20,%,n~/.viminfo

function! ResCur()
  if line("'/"") <= line("$")
    normal! g`"
    return 1
  endif
endfunction

" Restore cursor to file position in previous editing session
augroup resCur
  autocmd!
  autocmd BufWinEnter * call ResCur()
augroup END





" ==============================================
" Mappings
" ==============================================
" use shell with ctrl-z
map <C-Z> :shell


" line numbering
map <LEADER>ln :%s/^//=line('.')/<CR><ESC>

" add a comment
map ,c i/*  */<Left><Left><Left>


" use pon and poff instead of set no/paste
map <Leader>pon  :set paste<CR>$
imap <Leader>pon  <Esc>:set paste<CR>a$
map <Leader>poff :set nopaste<CR>$
imap <Leader>poff <Esc>:set nopaste<CR>a$

" convert text2html
map ,w :runtime! syntax/2html.vim
"spelling check
map <F2> :set spelllang=en<CR>:set spell!<CR><Bar>:echo "Spell Check: " . strpart("OffOn", 3 * &spell, 3)<CR>

原创粉丝点击