Vim helptag generation - vim

I use pathogen and have an update script that downloads the latest versions of all the vim plugins I use from vim.org, github, or wherever else they may be. However, this script does not currently update the vim helptags. In order to do so, I have to go to each updated plugin in vim and execute ":helptags doc/". It would be great if I could do so with my update script, but in order to do so I need to run the vim ":helptags" command from a script. Is this possible?
Thanks!

pathogen.vim versions after 1.2 (2010-01-17) have a pathogen#helptags function that will automatically update the help tags for each directory in the runtimepath. Just call it after you call pathogen#runtime_append_all_bundles:
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
Or, assuming you have call pathogen#runtime_append_all_bundles() in your .vimrc:
vim -c 'call pathogen#helptags()|q'
from the command line only once after you have fetched the updates.
Recent versions of pathogen recommend calling pathogen#infect() in your .vimrc instead of pathogen#runtime_append_all_bundles (since b147125 “Add pathogen#infect() as primary entry point for basic setup”, 2011-05-13; the former calls the latter internally). If your .vimrc is calling pathogen#infect(), then put your call to pathogen#helptags() after that.

Shouldn't all of the documentation be in the same doc directory? Maybe .vim/doc, /usr/share/vim/vimfiles/doc?
In any case, you can launch vim, and direct it to run a command:
cd <plugindir>
vim -c "helptags doc/"
You can specify multiple commands, so the last one can be -c q to have vim exit when you're done. (Or you can tack it on as one command, command1 | q.) Or, if you have many commands to run, you can generate a script, and have vim run it using vim -S <script>; again, you can make the last command of the script q so it closes when it's done.

In recent enough versions, :helptags ALL will work.

For some time pathogen provides the Helptags command that updates the documentation of all your bundles (and all other directories that are part of the runtimepath).
Thus, it's sufficient to call
:Helptags
after your Vim plugin collection has changed. Possibly even automatically by calling e.g. vim -c Helptags -c q from your update script.

Related

Vim(Gvim) - How do I install a script on Windows 7?

I want to install this closetag.vim script:
http://vim.sourceforge.net/scripts/script.php?script_id=13
It says
place this file in your standard vim scripts directory and source it
while editing the file you wish to close tags in.
And this is shown as an example:
:let g:closetag_html_style=1
:source ~/.vim/scripts/closetag.vim
1) What is my standard vim scripts directory on W7?
I have neither .vim nor scripts folder on my system. And if I have\am expected to create one (or ones) where should it (they) be placed? %ProgramFiles%\Vim\vim80 or %ProgramFiles%\Vim\vimfiles or maybe somewhere else?
1.1) Also, this might be a silly thing to ask about, but why do I keep seeing that tilde in path almost every time I read about Vim. Does it mean that Vim is used primarily by Mac/Linux people? Why is that?
2) What does it mean to source the script? Run a command like this let g:closetag_html_style=1 in command mode in Vim?
Btw what does style=1 mean here?
And if I want it to work by default for all html\xhtml\xml files, what do I do? Put this command to _vimrc file?
Thank you so much!
You could find the answers to all your questions just by reading the plugin description carefully. Unfortunately, it is both poorly written and factually incorrect.
What is my standard vim scripts directory on W7?
On Windows, you are supposed to put custom and third-party scripts in various places under:
C:\Users\username\vimfiles\
But that's not what the author means by "standard vim scripts directory". What he is referring to is this:
C:\Users\username\vimfiles\scripts\
which is not standard at all.
Also, this might be a silly thing to ask about, but why do I keep seeing that tilde in path almost every time I read about Vim. Does it mean that Vim is used primarily by Mac/Linux people? Why is that?
Yes, Vim is primarily used by UNIX-like systems users. Because of history.
What does it mean to source the script? Run a command like this let g:closetag_html_style=1 in command mode in Vim?
No. Read your question again.
Btw what does style=1 mean here?
Nothing.
But :let g:closetag_html_style=1 means "set the g:closetag_html_style option to true".
And if I want it to work by default for all html\xhtml\xml files, what do I do? Put this command to _vimrc file?
No. This is explained on the plugin's page:
For greater convenience, load this script in an autocommand:
:au Filetype html,xml,xsl source ~/.vim/scripts/closetag.vim
Which is wrong on many levels.
Here is what you actually have to do to use that script:
Save the closetag.vim script to the following location:
C:\Users\username\vimfiles\scripts\closetag.vim
Create vimfiles\ and/or vimfiles\scripts\ if they don't exist.
Add the lines below to C:\Users\username\_vimrc:
augroup closetag
autocmd!
autocmd Filetype html,xhtml,xml,xsl runtime scripts/closetag.vim
augroup END
let g:closetag_html_style = 1
Reference:
:help startup
:help :source
:help :runtime
:help :let
:help autocommand

vundle: ConqueTerm: not an edit command

I tried to install Conque-Shell via Vundle, and when I input :ConqueTerm bash in vim, it showed 'ConqueTerm: Not an edit command'. I thought there was something wrong with my path. But I did write set rtp+=~/.vim/bundle/vundle in my .gvimrc. And the configure of Vundle is at the beginning of the .gvimrc.
I copied the .vim/bundle/Conque-Shell/plugin/conque_term.vim to .vim/plugin/conque_term.vim and then it worked.
So, is there anything wrong with my .gvimrc?? Thanks!
My .gvimrc: https://gist.github.com/guori12321/5506991
If you observe the output of :scriptnames (the list of scripts sourced during startup), you'll note that .gvimrc comes last, after .vimrc and the plugins. Therefore, any changes to the 'runtimepath' there are too late; plugins (like ConqueTerm) have already been loaded. You can read more about the startup process at :help initialization.
Even if you only use the GUI GVIM, put the common settings into ~/.vimrc; the ~/.gvimrc file is for GUI-only stuff that doesn't apply to the terminal Vim, e.g. setting 'guifont' and similar options.

How to tell Vim not to use ~/.vim

By default Vim is looking for plugins and other stuff in ~/.vim.
Is there any way to tell Vim to search for plugins, etc. in ~/.other_folder and force it to ignore ~/.vim entirely?
Vim uses the comma-separated paths from 'runtimepath' to determine where to look for :runtime'd files.
You can change that option either in ~/.vimrc (which is sourced as the very first script), or by passing the set rtp=... commands on Vim's command-line via --cmd (the commands passed with -c are only applied after startup).

Vim - run ant command with current file as an argument

In my IDE (webstorm) I have configured an external tool to run ant like so:
ant myTarget -DfileNoExt="$FileNameWithoutExtension$"
the $FileNameWithoutExtension$ is expanded by the IDE when the command is run.
I am transitioning to using Vim. I am a Vim n00b.
How do I do the same with Vim (MacVim specifically)?
Vim will expand % as the current file. You can use modifiers on it (see :help filename-modifiers). You can tell vim to use ant as your make program:
compiler ant
setlocal makeprg=ant\ myTarget\ -DfileNoExt=\"%:t:r\"
Now you can use :make to build your current file. You should get build errors in your quickfix (view it with :copen).
You probably want to put the above script into a file ~/.vim/after/ftplugin/java.vim. That will load it for every java file you open.
Note that if you want to use different targets, :make will pass all arguments to ant. So :make otherTarget will execute ant myTarget -DfileNoExt="file" otherTarget.
you can map either Hotkey or Your own key-sequence in vim.rc(not sure in mac, should have similar resource file)
add this line to your vim resource file:
imap <F5> <ESC><ESC>:!ant mytarget -Dfilenoext=\"%<\"
which means when you editing the source code, press F5 will run your ant tool
for more, you can read http://vim.wikia.com/wiki/Compile_Java_with_Sun_JDK_javac and http://www.vim.org/scripts/script.php?script_id=155

How to turn-off a plugin in Vim temporarily?

I have multiple plugins in Vim and some of them modify the default behavior of Vim. For example I use Vimacs plugin, which makes Vim behave like emacs in the insert mode alone. Sometime I want to turn off the Vimacs plugin without moving the vimacs.vim out of the plugins directory. Is there a way to do it?
You can do this if you use a plugin manager like Vundle or Pathogen, which will keep the plugin in its own directory underneath the ~/.vim/bundle/ directory.
In that case, just find out the runtimepath of the vimacs plugin with the following command:
set runtimepath?
Let's say it's ~/.vim/bundle/vimacs.
Then, put this command in your .vimrc:
set runtimepath-=~/.vim/bundle/vimacs
To load vimacs, just comment that line out and relaunch Vim (or source your .vimrc).
See which variable vimacs check on start. On the begin of the script file find something Like if exists('g:vimacs_is_loaded").... Then set this variable in your .vimrc or while start vim with vim --cmd "let g:vimacs_is_loaded = 1".
In case you are using pathogen, this post gives a better answer, in my opinion. Since I have frequent need to disable snippets when using latex, also added this in my ~/.config/ranger/rc.conf:
map bs shell vim --cmd "let g:pathogen_blacklist = [ 'ultisnips', 'vim-snipmate' ]" %f
This way, whenever I want to open a file with snippets disabled, it is easy.

Resources