Vi: Difference between revisions

From miki
Jump to navigation Jump to search
(/)
Line 12: Line 12:
*** Direct links: [http://www.viemu.com/vi-vim-cheat-sheet.gif overview] and [http://www.viemu.com/vi-vim-tutorial-svg.zip per-lesson].
*** Direct links: [http://www.viemu.com/vi-vim-cheat-sheet.gif overview] and [http://www.viemu.com/vi-vim-tutorial-svg.zip per-lesson].


== Some Stuff ==
== Keyboard Shortcuts ==
* To enable syntax highlighting + numbering:


<font color="red">''! If keys JKLMH have been remapped to HJKLM, shortcut below must be changed accordingly'' !</font>
:syntax enable
:set bg=light ''#Use set bg=dark if console background color is dark''
:set number


{| class="wikitable"
* Use '''Ctrl+[''' instead of '''Esc'''. It has same effect (same keycode) but it's faster to type. It also works on ''AZERTY'' keyboard.
!Shortcut
**... but so far not in ''AndLinux''...
!Description
!Custom
|-
|'''Ctrl+<tt>[</tt>'''
|Same effect as '''Esc''', but a bit faster/easier to type. Also works on ''AZERTY'' keyboard (but apparently not for AndLinux, snif!)
|
|-
|'''<tt>*</tt>'''
|Search next occurence of word under cursor (Here [http://vim.wikia.com/wiki/VimTip1 more] like this...)
|
|-
|'''<tt>#</tt>'''
|Search previous occurence of word under cursor
|
|-
|'''<tt>gd</tt>'''
|Search first occurence of current search
|
|}

== Some Stuff to Add in <tt>~/vimrc</tt> file ==
''(remarks: command in <tt>~/vimrc</tt> file must not be prefixed with a colon :)''
* To enable syntax highlighting + numbering:
syntax enable
set bg=light ''#Use set bg=dark if console background color is dark''
set number
* To remap movement key bindings to JKLM (instead of HJKL, so that they are right under right hand fingers on ''AZERTY'' keyboards). Commands on key 'M' are now on key 'H'.
nnoremap j h
nnoremap k j
nnoremap l k
nnoremap m l
nnoremap h m
vnoremap j h
vnoremap k j
vnoremap l k
vnoremap m l
vnoremap h m

Revision as of 21:39, 8 September 2008

Links

  • General
  • Fun
    • Vi would not be vi without a bit of fun...
    • Very funny material related to emacs vs. vi [1].
  • Guides & Cheat sheets
    • Very good post explaining why vi is superior and defeating common misconception (with examples) [2].
    • Very good graphical cheatsheet

Keyboard Shortcuts

! If keys JKLMH have been remapped to HJKLM, shortcut below must be changed accordingly !

Shortcut Description Custom
Ctrl+[ Same effect as Esc, but a bit faster/easier to type. Also works on AZERTY keyboard (but apparently not for AndLinux, snif!)
* Search next occurence of word under cursor (Here more like this...)
# Search previous occurence of word under cursor
gd Search first occurence of current search

Some Stuff to Add in ~/vimrc file

(remarks: command in ~/vimrc file must not be prefixed with a colon :)

  • To enable syntax highlighting + numbering:
syntax enable
set bg=light          #Use set bg=dark if console background color is dark
set number
  • To remap movement key bindings to JKLM (instead of HJKL, so that they are right under right hand fingers on AZERTY keyboards). Commands on key 'M' are now on key 'H'.
nnoremap j h
nnoremap k j
nnoremap l k
nnoremap m l
nnoremap h m
vnoremap j h
vnoremap k j
vnoremap l k
vnoremap m l
vnoremap h m