Chapter 8 Basic Abbreviations, Keyboard Mapping, and Initialization Files
enable you to automate repetitive tasks
abbreviation: enables you to type in part of a word and let Vim type the rest
remap the keyboard: redefine a key to be a whole set of commands
save them to an initialization file that will automatically be read the next tiem you start Vim
Abbreviations
:abbreviate ad advertisement
??????But how to remove one abbreviation??????
about <space>: it is really very amazing!
Usually Vim ignores spaces between the abbreviation and the expansion, to avoid that problem, you can use <space> istead!
Example:
:abbreviate #b /*************************************** (40 chars, designed so that the right side is aligned to a tab stop)
:abbreviate #e <space>**************************************/
Mapping
suppose you need to surround certain words with curly braces
Example: change a word 'amount' into '{amount}'
:map <F5> i{<Esc>ea}<Esc>
1. there is an implicit <Enter>
2. you can either press F5 key or by entering the characters < F 5 >
3. you must enter <Esc> as characters, or type CTRL-V followed by the <Esc> key (the CTRL-V tells Vim literally instead of acting on it.)
Listing Your Mappings
:map
Saving Your Settings
:mkvimrc file: writes all your settings to a file
:source fiel: read file
During startup, Vim editor looks for an initialization file. If it is found, it is automatically executed. (Only the first file found is read.)
UNIX
$HOME/.vimrc
$HOME/_vimrc
$HOME/.exrc
$HOME/_exrc
One way to find out which initialization files are read is to use the :version command
:version
.exrc is used by the old Vi editor
:mkexrc: writes the mappings to the .exrc file
Vim Tutorial Study(8)
最新推荐文章于 2025-04-07 17:41:11 发布