Vim
(→Configuration) |
m |
||
(5 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
- | Vim is a text editor based off the classic [[Documentation/devtools/maemo5/vi|vi editor]]. It is different from other text editors in that it has different modes of operation. You can learn about vim through various websites. | + | Vim is a text editor based off the classic [[Documentation/devtools/maemo5/vi|vi editor]]. It is different from other text editors in that it has different modes of operation. You can learn about vim through [http://www.google.com/search?q=vim+tutorial various websites]. |
Vim is a very capable editor for mobile devices because of its low footprint and efficiency of key strokes. | Vim is a very capable editor for mobile devices because of its low footprint and efficiency of key strokes. | ||
+ | |||
+ | == Installation == | ||
+ | Vim can be installed from the [[Extras|extras repository]]. | ||
== Configuration == | == Configuration == | ||
Line 23: | Line 26: | ||
" Use 256 colors | " Use 256 colors | ||
set t_Co=256 | set t_Co=256 | ||
+ | |||
+ | " Ctrl-Space (layout switcher) does nothing | ||
+ | imap <Nul> <Nop> | ||
+ | map <Nul> <Nop> | ||
+ | vmap <Nul> <Nop> | ||
+ | cmap <Nul> <Nop> | ||
+ | nmap <Nul> <Nop> | ||
</pre> | </pre> | ||
+ | |||
+ | == Finger scrolling == | ||
+ | |||
+ | Add the following to your <code>~/.vimrc</code> to enable scrolling by dragging the screen. | ||
+ | |||
+ | <pre> | ||
+ | " Drag scrolling. Taken from the ez_scroll vim script | ||
+ | " http://www.vim.org/scripts/script.php?script_id=3141 | ||
+ | |||
+ | func! MScroll() | ||
+ | let l:done=0 | ||
+ | let l:n = -1 | ||
+ | let l:w0 = line("w0") | ||
+ | let l:last = line("$") | ||
+ | while done!=1 | ||
+ | let l:g = getchar() | ||
+ | if l:g != "\<LeftDrag>" | ||
+ | let done = 1 | ||
+ | else | ||
+ | if l:n == -1 | ||
+ | let l:n = v:mouse_lnum | ||
+ | let l:fln = v:mouse_lnum | ||
+ | else | ||
+ | let l:new = l:w0 - v:mouse_lnum + l:n | ||
+ | if l:new<1 | ||
+ | let l:new = 1 | ||
+ | endif | ||
+ | |||
+ | let l:diff = -v:mouse_lnum + l:n | ||
+ | let l:nd = line("w$") | ||
+ | if l:nd+l:diff>l:last | ||
+ | let l:new = l:last - winheight(0) + 1 | ||
+ | if l:new<1 | ||
+ | let l:new = 1 | ||
+ | endif | ||
+ | end | ||
+ | |||
+ | let l:wn = "normal ".string(l:new)."zt" | ||
+ | if (l:n != v:mouse_lnum) | ||
+ | exec(l:wn) | ||
+ | redraw | ||
+ | endif | ||
+ | let l:w0 = line("w0") | ||
+ | let l:n = v:mouse_lnum + l:diff | ||
+ | endif | ||
+ | endif | ||
+ | endwhile | ||
+ | :call cursor(v:mouse_lnum,v:mouse_col) | ||
+ | endfunc | ||
+ | :set mouse=a | ||
+ | :noremap <silent> <LeftMouse> :call MScroll()<CR> | ||
+ | :noremap <LeftRelease> <Nop> | ||
+ | :noremap <LeftDrag> <Nop> | ||
+ | </pre> | ||
+ | |||
[[Category:Software]] | [[Category:Software]] |
Latest revision as of 11:58, 31 May 2011
Vim is a text editor based off the classic vi editor. It is different from other text editors in that it has different modes of operation. You can learn about vim through various websites.
Vim is a very capable editor for mobile devices because of its low footprint and efficiency of key strokes.
[edit] Installation
Vim can be installed from the extras repository.
[edit] Configuration
Vim can be configured through the ~/.vimrc
file. Here are some items that make it easier to use vim on the N900.
" Map the comma key to colon map , : " Press jj while in insert mode to press escape inoremap jj <esc> " CTRL+Up to page up, CTRL+Down to page down map <c-up> <c-u> map <c-down> <c-d> " Use 256 colors set t_Co=256 " Ctrl-Space (layout switcher) does nothing imap <Nul> <Nop> map <Nul> <Nop> vmap <Nul> <Nop> cmap <Nul> <Nop> nmap <Nul> <Nop>
[edit] Finger scrolling
Add the following to your ~/.vimrc
to enable scrolling by dragging the screen.
" Drag scrolling. Taken from the ez_scroll vim script " http://www.vim.org/scripts/script.php?script_id=3141 func! MScroll() let l:done=0 let l:n = -1 let l:w0 = line("w0") let l:last = line("$") while done!=1 let l:g = getchar() if l:g != "\<LeftDrag>" let done = 1 else if l:n == -1 let l:n = v:mouse_lnum let l:fln = v:mouse_lnum else let l:new = l:w0 - v:mouse_lnum + l:n if l:new<1 let l:new = 1 endif let l:diff = -v:mouse_lnum + l:n let l:nd = line("w$") if l:nd+l:diff>l:last let l:new = l:last - winheight(0) + 1 if l:new<1 let l:new = 1 endif end let l:wn = "normal ".string(l:new)."zt" if (l:n != v:mouse_lnum) exec(l:wn) redraw endif let l:w0 = line("w0") let l:n = v:mouse_lnum + l:diff endif endif endwhile :call cursor(v:mouse_lnum,v:mouse_col) endfunc :set mouse=a :noremap <silent> <LeftMouse> :call MScroll()<CR> :noremap <LeftRelease> <Nop> :noremap <LeftDrag> <Nop>
- This page was last modified on 31 May 2011, at 11:58.
- This page has been accessed 7,794 times.