Penguin

Differences between version 12 and predecessor to the previous major change of VimNotes.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 12 Last edited on Monday, June 4, 2007 4:39:11 pm by AristotlePagaltzis Revert
Older page: version 11 Last edited on Monday, June 4, 2007 3:45:46 pm by BenStaz Revert
@@ -1,48 +1,36 @@
 See also ViNotes 
  
 vim(1) -- potentially the most powerful editor unix users have access to, and one of the best things about it is in actual fact it's not restricted to unix users at all. Anybody can use vim, anywhere (more or less). Its only real drawback is that it's a little difficult to get to grips with at first. This page is not designed to cover basic editing. Rather, this page is a list of tips which will make your vim editing experience more enjoyable, particularly if vim is used as a programming editor. 
  
-!!Indentation 
+!! Indentation 
  
 [BenStaz] finds these settings very useful when using vim for coding (any language). 
  
 <verbatim> 
-set tabstop=4  
-set shiftwidth=4  
-set expandtab  
-set softtabstop=4  
-set autoindent 
+set tabstop=4 " 4 places per tab character  
+set shiftwidth=4 " indent/outdent by 4 places  
+set expandtab " convert hardtabs to the equivalent number of blanks  
+set softtabstop=4 " same value as 'tabstop' == no soft tabstops  
+set autoindent " indent of new lines as appropriate  
 </verbatim> 
  
-Just add the above to ''~~/.vimrc''. (Create it if it does not already exist)  
+!! Syntax Highlighting  
  
-*tabstop =4 - A four-space tab indent width  
+vim, of course, supports syntax highlighting. Often this isn't on by default. The easiest way to turn this on is to type <tt>:syntax on</tt>. Voila. What's that? You're using a dark background and the highlighting looks terrible? No real problem. Try <tt>:set background =dark</tt>. If you just think it looks horrible, full stop, get a new colourscheme... they’re available from vim.org and go into your <tt>~~/.vim/colors</tt> directory (which you may have to create). Select a different colour scheme using the <tt>:colorscheme</tt> command (see <tt>:help colorscheme</tt>; note that TabCompletion after the command works as you’d expect).  
  
-*shiftwidth=4 - This allows you to use the < and > keys from VIM's visual (marking) mode to block indent/unindent regions  
+If you run vim in the terminal your colour schemes are by default limited to 16 colours. Some terminals such as xterm can be compiled with 256 color support. To enable vim to use these add the following lines to your .vimrc:  
  
-*expandtab - Insert spaces instead of <TAB> character when the <TAB> key is pressed. (Used to avoid indenting problems with python)  
-  
-*softtabstop=4 - This makes it easier when pressing BACKSPACE or DELETE, since if the indent is using spaces it will take 4 keystrokes to delete the indent. Using this setting, however, makes VIM see multiple space characters as tabstops, and so <BS> does the right thing and will delete four spaces.  
-  
-*autoindent - Means that when you press RETURN and a new line is created, the indent of the new line will match that of the previous line.  
-  
-!!Syntax Highlighting  
-  
-vim, of course, supports syntax highlighting. Often this isn't on by default. The easiest way to turn this on is to type ":syntax on". Viola. What's that? You're using a dark background and the highlighting looks terrible? No real problem. Try ":set background=dark". Adjust as appropriate for 'it looks horrible and I have a white background'. If you just think it looks horrible fullstop, you can get a new syntax highlighting file for it... download one from vim.org, throw it into your ~/.vim/colors directory (you may have to create this) and explore the colorscheme command (hint, ":help colorscheme" or just ":colorscheme x", where your scheme file is x.vim). I recommend borland.vim, the colorscheme for the borland "Turbo" IDEs.  
-  
-If you run vim in the terminal your colour schemes are by default limited to 16 colours. Some terminals such as xterm can be compiled with 256 color support. To enable vim to use these add the following lines to your .vimrc:  
-<pre
+<verbatim
 " Enable 256 colors 
 set t_Co=256 
 set t_AB=^[[48;5;%dm 
 set t_AF=^[[38;5;%dm 
-</pre
+</verbatim
  
 Note that the ^[ should be a literal escape character. 
  
-Most vim colour schemes will need to be customised a little to look decent in this mode although some such as xterm16 are designed for it.  
-  
+Most vim colourschemes will need to be customised a little to look decent in this mode although some ( such as xterm16) are designed for it. 
  
 You can automatically enable syntax highlighting when starting a new vim text. vim is smart and can automatically adjust the highlighting by looking at the extension of the file. For example, ''vim test.py'' will automatically have python syntax highlighting. 
  
 If you are already in a document and wish to enable syntax highlighting, then use this command. 
@@ -59,13 +47,8 @@
  
 What syntax highlighting language is currently being used? 
  
 *:set filetype 
-  
-  
-  
-  
-  
  
 --KurtGaastra 
  
 !!Compiling 
@@ -104,36 +87,43 @@
  
 --DanielLawson 
  
 !!Character Encoding/Unicode 
-Vim has several options to do with character encoding, and each does slightly  
-different things.  
-* __encoding__ is used by vim internally for strings held in buffers, registers, expressions, etc.  
-* __termencoding__ is used to tell vim what encoding to display to the terminal, and it will convert text from its internal encoding to this encoding if necessary for display.  
-* __fileencoding__ is the encoding that files are assumed to be encoded with on disk, although vim will try to auto-detect this. __vim will default to latin1 (iso-8859-1) if it can't detect the encoding!__.  
-* __fileencodings__ is a list of encodings that vim will use when autodetecting files on load.  
  
-If you want to be modern, and only use utf -8 everywhere, put the following in your  
-$HOME/ .vimrc file:  
-<pre >  
- set encoding=utf-8  
- set termencoding=utf-8  
- set fileencoding=utf-8  
-</pre
+''This section is partially wrong and needs some cleanup.'' —AristotlePagaltzis  
+  
+Vim has several options to do with character encoding, and each does slightly different things.  
+  
+<tt>encoding</tt>:  
+ Used by vim internally for strings held in buffers, registers, expressions, etc.  
+<tt>termencoding</tt>:  
+ Tells vim what encoding to display to the terminal, and it will convert text from its internal encoding to this encoding if necessary for display.  
+<tt>fileencoding</tt>:  
+ The encoding that files are assumed to be encoded with on disk. Vim will try to auto-detect this; see the following:  
+<tt>fileencodings</tt>:  
+ A list of encodings that vim will try, in the order given, when autodetecting the encoding of a file on load. If it can't detect the encoding, it falls back to latin1 (aka iso-8859-1).  
+  
+ If you want to be modern, and only use [UTF -8] everywhere, put the following in your <tt> .vimrc</tt> file:  
+  
+<verbatim >  
+set encoding=utf-8  
+set termencoding=utf-8  
+set fileencoding=utf-8  
+</verbatim
  
 If you might ever use vim to edit raw binary data, then it's a good idea to make 
 sure that vim doesn't try any conversation on file load: 
-<pre>  
- " leave these as blank, so no conversation done?  
- set fileencoding=  
- set fileencodings=  
-</pre>  
  
-!!Display invisible characters such as Tab and the end-of-line character.  
+<verbatim>  
+" leave these as blank, so no conversation done?  
+set fileencoding=  
+set fileencodings=  
+</verbatim>  
  
-In command mode, type '':set list''  
+!! Miscellaneous  
  
-----  
+Display invisible characters such as Tab and the end -of -line character :  
+ <tt>:set list</tt>  
  
-There is a good vim reference guide [here|http://www.dc.turkuamk.fi/docs/soft/vim/vim.html]  
+!!! See also  
  
-----  
+* [Good vim reference guide | http://www.dc.turkuamk.fi/docs/soft/vim/vim.html]