Vim
(→Configuration) |
(→Configuration) |
||
Line 24: | Line 24: | ||
set t_Co=256 | set t_Co=256 | ||
</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]] |
Revision as of 09:16, 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.
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
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>