Upload
andrew-yi
View
169
Download
8
Embed Size (px)
DESCRIPTION
vim trial. Introduced the basic info
Citation preview
LOGO
Vi iMproved入门
Contents
Basics1
Vim as notepad2
Vim as IDE4
miscellaneous5
Advanced concepts3
Contents
Basics1
Basic – background info
Vim means Vi Improved
first released publicly in 1991
license is compatible with GPL
Popular with GNU/Linux
Basic – give up it
Learning vim is difficult
Basic – version
Latest release: 7.4
Please update to latest version Plugins Tab edit mode :help version7
Basic – platform
gVim
Basic – mode
Normal
CommandInsert
I/O/A…
Esc/Ctrl+C Q/:
Visual/Esc
Contents
Vim as notepad2
Vim as notepad – Insert
Ctrl-y/e: copy chars from prev/next line
Ctrl-n/p:auto complete word
Vim as notepad – Normal
Begin to Insert:I: insert at the beginning of line
A: insert at the end of line a: insert after cursor O: start new line upon current line o: start new line below
Vim as notepad – Normal
Move within line:$: move to the end0: move to the beginning of linew: move a word forwardb: move a word backwardf+char: move to next charF+char: move to prev char
Vim as notepad – Normal
Move within page:H: high / on topM: middle / in them middleL: low / at bottom
Move within file:Ctrl-f: forward by pageCtrl-b: backward by page
Vim as notepad – Normal
Move globally:G: to the end of filegg: to the start of tilenumber+gg: to specified line% on {[()]}: the mapping bracket
Vim as notepad – Normal
Find word when cursor on word:
*: forward#: backward
Find word with input word:/: forward?: backward
n to repeat and N to reverse repeat
Vim as notepad – Normal
selection(also visual)shift+v: select linectrl+v: select blockv: select char sequences
And then?y: copyp: pasted:delete
Vim as notepad – command
set nuset hlsearchset ignorecaseset tabstop=4set wrap……
Vim as notepad – window
:edit filename:tabedit filename:split filename:vsplit filename
Ctrl-w + Ctrl-w/hjkl: jump between windows
Contents
Advanced concepts3
Advanced – get help
use :help xxx
Just google it
Advanced – encoding
:set fileencodings?
:set encoding?
:set fileencoding?
Advanced – scripts
Put the commands into a file then we get a script:
Script can:customize vimenhance functions
Advanced – scripts
Customize:File location:
File Name:
Advanced – scripts
:scriptnames<CR>
A bundle of script(s) set up a plugin
Advanced – buffer
:buffers
Window:
Tab:
Advanced – buffer
buffers and tab:Eclpse: (Ctrl-e)
vim buffexplorer:
Advanced – register
Registers:
Use “ to call them
Advanced – record/macros
q start record, q again to stop
It’s programmer’s way of thinking!
But there is no ‘if’
Use @ to loop
Contents
Vim as IDE4
Vim as IDE – preview
What IDE provides us with:1, project management2, file explorer3, multiple file editor4, auto-completion5, reference/jump to definition6, project compilation
Vim as IDE – preview
Project Mangement: Project
Vim as IDE – preview
File explorer: NERDTree
Vim as IDE – preview
Multiple file edit:bufexplorer/airline
Vim as IDE – preview
Auto-completion:omnicppcomplete
Vim as IDE – preview
reference/jump to definition:Taglist/Ctags
Vim as IDE – preview
Compilation:make: compilecc: show you current infocl: show you info listcw: open info windowcn: bring you to next err/warningcp: brin gyou to previous
Vim as IDE – scripts
Scripts used:ProjectBufexplorerNERDTreeOmnicppcompleteTaglistAirlineKolor.vimandrew’s vim – mine vimrc …
Vim as IDE – give it up
Too much labor work
Not as fast as you may expect
Not so intelligent
How to debug?
Vim as IDE – give it up
Life is short, use python.
Life is short, use an IDE.
Contents
miscellaneous5
Miscellaneous – websites
Official:http://www.vim.org/
Wiki:http://vim.wikia.com/wiki/Vim_Tips_Wiki
Miscellaneous – downloads
Download:http://www.vim.org/download.php
Sources:ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2
For windows:ftp://ftp.vim.org/pub/vim/pc/gvim74.exe
Miscellaneous – build
1, mkdir ${HOME}/personal_tools2, cd ${HOME}/personal_tools3, wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz24, tar xf vim-74.tar.bz25, cd vim74 && ./configure --with-features=huge --
prefix=${home}/personal_tools && make && make install
6, export PATH=${HOME}/personal_tools/bin:${PATH}7, vim
Miscellaneous – andrew
.vimrc vim.tar
LOGO