Penguin

Differences between version 11 and revision by previous author of VimNotes.

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

Newer page: version 11 Last edited on Monday, June 4, 2007 3:45:46 pm by BenStaz Revert
Older page: version 8 Last edited on Wednesday, November 29, 2006 1:49:39 pm by IanMcDonald Revert
@@ -1,7 +1,31 @@
 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  
+  
+[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  
+</verbatim>  
+  
+Just add the above to ''~~/.vimrc''. (Create it if it does not already exist)  
+  
+*tabstop=4 - A four-space tab indent width  
+  
+*shiftwidth=4 - This allows you to use the < and > keys from VIM's visual (marking) mode to block indent/unindent regions  
+  
+*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. 
@@ -11,13 +35,37 @@
 " Enable 256 colors 
 set t_Co=256 
 set t_AB=^[[48;5;%dm 
 set t_AF=^[[38;5;%dm 
-  
 </pre> 
+  
 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. 
+  
+  
+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.  
+  
+*:set filetype=<language>  
+  
+eg: for python highlighting:  
+  
+*:set filetype=python  
+  
+or bash Highlighting:  
+  
+*:set filetype=sh  
+  
+What syntax highlighting language is currently being used?  
+  
+*:set filetype  
+  
+  
+  
+  
+  
  
 --KurtGaastra 
  
 !!Compiling 
@@ -78,10 +126,14 @@
  " 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.  
+  
+In command mode, type '':set list''  
  
 ---- 
  
 There is a good vim reference guide [here|http://www.dc.turkuamk.fi/docs/soft/vim/vim.html] 
  
 ----