and
<<Have a nice and easy use of plugins |
basic postfix abbreviations >>
not logged in (login)
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #592: Smart <Home> and <End> keymaps
tip karma
Rating 24/11, Viewed by 1112
created:
October 26, 2003 2:30
complexity:
basic
author:
Fabio G. Strozzi
as of Vim:
5.7
I found interesting the way <Home> and <End> keys act in some editors and I wondered why try not
carry it out with Vim.
Put the following lines in your ~/.vimrc and so <Home> will move the cursor between the first column and
the first non-blank character. <End> is similar but work at the end of the line.
I think this should be very useful to the indented code and trailing characters.
let g:home_key = '0'
let g:end_key = '$'
function ToggleHome()
exe "normal! \<Esc>".g:home_key
let g:home_key = g:home_key == '0'? '^' : '0'
endfunction
function ToggleEnd()
exe "normal! \<Esc>".g:end_key
let g:end_key = g:end_key == '$'? 'g_' : '$'
endfunction
inoremap <silent> <Home> <Esc>:call ToggleHome()<CR>i
nnoremap <silent> <Home> :call ToggleHome()<CR>
inoremap <silent> <End> <Esc>:call ToggleEnd()<CR>a
nnoremap <silent> <End> :call ToggleEnd()<CR>
Additional Notes
If you have questions or remarks about this site, visit the
vimonline development pages.
Please use this site responsibly.
Questions about Vim should go
to [email protected] after searching
the archive.
Help Bram help Uganda.