I am now using pathogen and GitHub to manage my vim plugins.
They are not difficult to use, but you need a few git commands to set it up, which I found very annoying.
To init .vim folder in Linux (or vimfiles for Windows), type:
mkdir .vim
cd .vim
git init
wget https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim -P ~/.vim/autoload
git add .
git commit -m 'initial commit'
To install each vim plugin, type: (here I use neocomplcache-snippets-complete as an example)
git submodule add https://github.com/Shougo/neocomplcache-snippets-complete.git bundle/neocomplacahe-snippets-complete
git add .gitmodules bundle/neocomplcache-snippets-complete
git submodule init
Apr 25, 2012
HOWTO: use pathogen to manage vim plugins
Posted by Lono at 10:45 0 comments
Labels: VIM
Jul 11, 2011
A Sleep function for VIM
I need to let VIM wait for cscope.exe to rebuild the tag file, but there are no build-in sleep function for VIM, so I made one here:
"a sleep function which allows vim to wait for the other processes to finish
com! -complete=command -nargs=+ Sleep call s:Sleep(<q-args>)
fun! s:Sleep(millisec)
  let ct = localtime()
  let dt = 0
  while dt < (a:millisec/1000)
    let dt = localtime() - ct
  endwhile
endfun
Just put it into your _vimrc.
To invoke it, type ":Sleep 10000" to let VIM wait for 10 secs.
Posted by Lono at 23:04 0 comments
Labels: VIM
Jun 17, 2010
SuperTab complete for neocomplcache
As I said in my previous post, neocomplcache is a very powerful vim plugin.
It incoporates the funtionality of SnipMate and AutoComplPop while providing efficient search
for potential completion items.
However, SuperTab does not support neocomplcache. It is very bad since I like to tab complete
everything, including snippets. Here is the solution -- put the following in you .vimrc:
The above setting allows you to trigger a snippet with "tab" key when possible. If not, it will simply trigger omni completion. I set it to complete the longest common string. It is just a personal taste. You can set it to other type of completion as well.
*Update 2010/12/11 for necomplcache V5.2 compatiblity
*Update 2012/04/24 for necomplcache V7 compatiblity
Posted by Lono at 16:25 2 comments
Labels: VIM
Mar 6, 2010
open files in new tabs of GVIM from command line
Name the following file gvim.bat
and put it into C:\Windows
@echo off
start gvim.exe -p --remote-tab-silent "%1"
echo on
Posted by Lono at 07:21 0 comments
Labels: VIM
Feb 17, 2010
Hacking SuperTab.vim
I have been unhappy about the longest common text of auto-complete
provided by VIM for a long long time.
I try to find a good solution on the Internet, but all I got is
Put
completeopt += menuone,longest
in your .vimrc
It does provide a longest common text of auto-complete FOR THE FIRST
TIME. After I type one more character and press <tab>, it just
starts to move on the popup menu. No more longest common text of all
matches anymore.
To work around this, I hacked the
SuperTab
to provide longest common text.
Here is how:
- open supertab.vim in your /plugin directory
- find function! s:SuperTab(command)
- change the code
" handle 'context' completion.
if b:complType == 'context'
let complType = s:ContextCompletion()
if complType == ''
exec "let complType = \"" .
\ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
endif
return complType . key
endif
to
" handle 'context' completion.
if b:complType == 'context'
let complType = s:ContextCompletion()
if complType == ''
exec "let complType = \"" .
\ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
endif
if pumvisible()
return "\<ESC>a" . complType . key
else
return complType . key
endif
endifThe idea is simple. Just close the popup menu each time users press <tab>
Posted by Lono at 18:30 0 comments
Labels: VIM
Feb 15, 2010
The plugin list of VIM
It's time to organize my VIM plugins
My VIM Plugin Lists
-
SnipMate– provide TextMate like snippet.Use neocomplcache instead -
SuperTab– use tab to complete words or sentenceUse neocomplcache instead Can be configured to use tab key to trigger the snippet and word complete at the same time. Very cool~~~ - FuzzyFinder – find files and functions in an instant
- L9 – required for new version of FuzzyFinder
- EnhancedCommentify– comment and uncomment a piece of codes with single keystroke
- DoxygenToolkit – generate function comment
- a.vim – switch between .cpp and .h files
-
visual_studio.vim – compile VS files in VIMNot compatible with VS2010, -
omnicppcomplete– complete c++ filesUse neocomplcache instead - surround.vim – make hello_world to "hello_world" with few key strokes
- repeat.vim – make "surround" operation repeatable(with ".")
- vim-latex – latex syntax support
- matlab_run.vim – run matlab script in vim
- matlab plugin for vim – provide syntax highlighting and indention of matlab
-
tlib– provides utilities for vikiUse AsciiDoc instead -
viki– support viki ( a kind of wiki language )Use AsciiDoc instead - neocomplcache – it has been actively developed during recent months. It's mature enough. It's interesting to see the author reply every blog which has questions about this plugin. It seems that the author really cares about his work.
- neocomplcache-snippets-complete – since neocomplcache V7, the snippets have been separated from neocomplcache. You need to download it individually.
- delimitMate – parenthesis completion, very handy
- cscope_map – provide keyboard mapping for cscope
Required Software:
-
Deplate– convert viki to html - Python 2.4.4 – required by Visual_Studio.vim
Ruby 1.86 – required by Deplate- ctags – required for omni-complete
- cscope 15.7 – a better ctags for python. The zip file contains windows binary.
- Python for Windows Extension – required by Visual_Studio.vim
Abandoned plugins:
- taglist – use FuzzyFinder instead
- project – use FuzzyFinder instead
-
RltvNmbr – too slowincluded in VIM 7.3
- snippetsEmu – too old, use SnipMate instead
neocomplcache – too new. It is a combination ofomnicppcomplete,SnipMate,AutoComplPopandSuperTab. It doesn't not work properly if you set the same trigger key to complete and snippet. However, it supports nested snippet and longest common string complete. Very promising.
Plugins needs modified:
- visual_studio.vim
- needs to update error message format for visual studio 2008 to work (I set it to set errorformat= %#%f(%l) : %#%t%[A-z]%# %m )
- needs to change key binding to avoid conflicts with viki.vim ( I changed them from vc to ic)
- SnipMate.vim
- needs to update snippets (of course)
*Update 2011/03/10 for delimitMate
*Update 2011/07/11 for cscope
*Update 2012/04/24 for neocomplcache
Posted by Lono at 16:54 4 comments
Labels: VIM
Add VIM to the right-click menu
The default VIM 7.2 right-click menu will open the new file in the current buffer.
It's quite annoying because I want to open the new file in a new tab most of the time.
To solve the problem, just import the following setting to the windows registery
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Edit with &Vim\command]
@="\"c:\\Program Files\\Vim\\vim72\\gvim.exe\" -p --remote-tab-silent \"%1\""
Posted by Lono at 10:36 0 comments
Labels: VIM
Jan 28, 2010
VIM useful commands
gw exchange two words
CTRL-X CTRL-L complete line
CTRL-X CTRL-F complete file
CTRL-X CTRL-P complete word, useful when you use snippet and still want to have omni-complete
tab complete word
\s substitude the current word
\S substitude with question
ALT-O open file with the same name
\F find in all files
\g find file
\f find tag
,r run matlab script
,o open matlab
:make check matlab syntax
\ll compile latex
\lv view latex
Posted by Lono at 21:47 0 comments
Labels: VIM
Jun 28, 2009
VIM Color Theme (Ayende)

Oren Eini made a great color theme for Visual Studio. I ported it to VIM. You can get it here
Here is a list of my previous VIM themes:
1. AF.vim

2.VividChalk.vim (it's specialized for Ruby)

Posted by Lono at 05:11 0 comments
Jun 27, 2009
Use Consolas font in Japanese VIM
Consolas is a font which is specialized to display source codes.
To use the font in Japanese VIM, add the following line in .vimrc
set guifont=Consolas:h11:cSHIFTJIS
Then import the following into your registry and reboot.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
"Consolas"=hex(7):4d,00,49,00,4e,00,47,00,4c,00,49,00,55,00,2e,00,54,00,54,00,\
43,00,2c,00,4d,00,69,00,6e,00,67,00,4c,00,69,00,55,00,00,00,53,00,49,00,4d,\
00,53,00,55,00,4e,00,2e,00,54,00,54,00,43,00,2c,00,53,00,69,00,6d,00,53,00,\
75,00,6e,00,00,00,42,00,41,00,54,00,41,00,4e,00,47,00,2e,00,54,00,54,00,43,\
00,2c,00,42,00,61,00,74,00,61,00,6e,00,67,00,00,00,00,00
Since Consolas supports English only. It's necessary to tell system how to display the words in other Languages or all Japanese words cannot be display normally.
The above registry setting assign
"MINGLIU.TTC,MingLiU
SIMSUN.TTC,SimSun
BATANG.TTC,Batang" to Consolas font to display both Japanese and Chinese words.
The result is here:

To get into the nutshell, see how font linking works
Posted by Lono at 08:58 0 comments
Jun 20, 2009
The VIM Settings to replace Visual Studio 2008
Just start to shift from Visual Sudio 2008 to VIM. I heard that keyboards can bring a lot of fun to programming, but I cannot live without Visual Studio 2008. There are too many great features of it, like completion, source code browsing, etc. All I need to do now is to being these features into VIM. (Why does no one make a power pack of VIM to beat Visual Studio?)
1. SnipMate
Provide a Textmate-like snippet functionality. It's a better substitude of snippetsEmu. However, snippetsEmu has more snippets. Perhaps I should port them to SnipMate, hmm...
2. SuperTab
3. FuzzyFinder
4. CTAGs
5. EnhancedCommentify
6. DoxygenToolkit
7. a.vim
8. visual_Studio.vim
Used plugins:
1. taglist
2. project
3. RltvNmbr
Posted by Lono at 11:02 0 comments
Jun 17, 2009
Abandon Textmate...Now!!!
Textmate hasn't release any new versions for several years. I don't think a software does have a future if it's not actively supported. Therefore, I decided to switch to the old good VIM. Perhaps I could master VIM this time.
*Update 2011/11/15: There will be Textmate 2 alpha release around Christmas. After 2 years, it doesn't matter anymore. VIM FTW!
Posted by Lono at 20:32 1 comments
Feb 5, 2009
VIM
I am trying to adapt VIM in recent days. Still fill painful, though.
Here is my plugin list:
a.vim
include_complete.vim
supertab.vim
omnicppcomplete.vim
taglist.vim
visualmark.vim
Posted by Lono at 03:42 0 comments