(→Comments: visual version) |
Luc Hermitte (talk | contribs) (→Comments: copy-paste from the latest homeLikeVC++.vim) |
||
Line 27: | Line 27: | ||
==Comments== |
==Comments== |
||
Here is another way to do the same thing: |
Here is another way to do the same thing: |
||
− | http:// |
+ | [http://code.google.com/p/lh-vim/source/browse/cpp/trunk/plugin/homeLikeVC++.vim homeLikeVC++.vim] |
---- |
---- |
||
If you don't mind smashing a mark (<code>'h</code> in this case), you can use the map in visual mode, too: |
If you don't mind smashing a mark (<code>'h</code> in this case), you can use the map in visual mode, too: |
||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
+ | ---- |
||
− | <code><nowiki> |
||
+ | There is no need to smash any mark if we: |
||
⚫ | |||
+ | * return what must be executed instead of played with <tt>:normal!</tt> |
||
− | </nowiki></code> |
||
+ | * and then use @= |
||
+ | |||
+ | See the latest version of homeLikeVC++ (the link has been updated) |
Revision as of 23:17, 5 June 2008
Tip 315 Printable Monobook Previous Next
created August 14, 2002 · complexity advanced · author Alex A. Naanou · version 5.7
Put the following in your vimrc. When you press the Home key, the cursor will move to the first nonblank character on the line, or, if already at that position, the cursor will move to the first character.
function! SmartHome() let s:col = col(".") normal! ^ if s:col == col(".") normal! 0 endif endfunction nnoremap <silent> <Home> :call SmartHome()<CR> inoremap <silent> <Home> <C-O>:call SmartHome()<CR>
Comments
Here is another way to do the same thing: homeLikeVC++.vim
If you don't mind smashing a mark ('h
in this case), you can use the map in visual mode, too:
vnoremap <silent> <Home> <Esc>:call <SID>SmartHome()<CR>mhgvg`h
There is no need to smash any mark if we:
- return what must be executed instead of played with :normal!
- and then use @=
See the latest version of homeLikeVC++ (the link has been updated)