word autocomplete - Use abbreviations for frequently-used words
Similarly, in insert mode you can hit Ctrl+P or Ctrl+N to autocomplete. Ctrl+P searches upward in your text for what your trying to complete to, Ctrl+N searches forward in your text. After exhausting the current buffer, both of these commands will begin searching other open buffers. I'm not sure, but I believe that there is also a search path you can specify in the .vimrc if you wish.
--------------------------------------------------------------------------------
Use a dictionary file:
set complete+=k
set dictionary+=/your/dict/file
Ctrl+N, Ctr+P will now search for completions from that dict file.
--------------------------------------------------------------------------------
You can put your common typos as abbreviations, for auto correction:
iab teh the
iab seperate separate
--------------------------------------------------------------------------------
> How cut the space from the resulted substitution?
From :help abbreviations: An exception to this is the character <C-]>, which is used to expand an abbreviation without inserting any extra characters.
Example:
:ab hh hello
"hh<Space>" is expanded to "hello<Space>"
"hh<C-]>" is expanded to "hello"
--------------------------------------------------------------------------------
Use getchar() to eat up that space, for example:
iab <t <target name="%"></target><Esc>F%s<c-o>:call getchar()<CR>
--------------------------------------------------------------------------------
Regarding how to eat the last typed character (when it is a space): Use :Iabbr and :Inoreabbr from script#50.
--------------------------------------------------------------------------------
See the SuperTab plugin. It does almost all of this without the need for programming.
--------------------------------------------------------------------------------
To eat the last space, for example, with:
iab did <div id="
In insert mode, type did then press Ctrl-]
Result: The abbreviation is expanded with no extra characters, and you are still in insert mode and can continue typing.
Saturday, July 17, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment