Vim not recognizing some commands from vim-latex - vim

I have vim-latex installed via Vundle and I'm trying to disable some annoying mapping that it sets up by default. From the docs I know that, for example, I can use the following command to unmap FEM:
call IUNMAP('FEM','tex')
But when I type that I get the error E117: Unknown function: IUNMAP.
I have installed vim-latex with Vundle by including Plugin 'LaTeX-Suite-aka-Vim-LaTeX' in my vimrc and I have just used the PluginUpdate command to update everything, which runs with no error, so I should have the latest version of the package.
Am I missing something here?

Actually, the problem you're having is related to where you're getting your vim-latex from.
With:
Plug 'LaTeX-Suite-aka-Vim-LaTeX'
You're getting it from here, which you'll notice hasn't been updated since 2010. Looking at the plugin/imaps.vim file in that repository, you'll see there's a definition for function IMAP(), but not for IUNMAP(), which was probably introduced after the last date that repository was synced...
Use this source instead:
Plug 'vim-latex/vim-latex'
Which will get it from here which is an official maintained location for this plug-in.
If you look at plugin/imaps.vim in that source tree, you'll notice function! IUNMAP is defined there.
Updating to the correct plug-in location should fix this problem for you (together with probably quite a few fixes from the last 10 years!)

The functions IMAP() and IUNMAP() are loaded by the vim-latex plug-in only after your vimrc is processed. So you need to execute them from a context where they're available.
Furthermore, in order to have your unmapping succeed, you need to actually execute it after the mapping was created, and mappings are typically created when the filetype is set.
The documentation mentions that these overriding rules should be done in specific files:
An important thing to note is that if you wish to over-ride macros created by Latex-Suite rather than merely create new macros, you should place the IMAP() (or IUNMAP()) calls in a script which gets sourced after the files in Latex-Suite.
A good place typically is as a file-type plugin file in the ~/.vim/after/ftplugin/ directory. [...]
For example, to delete a mapping, you can use
call IUNMAP('FEM', 'tex')
in ~/.vim/after/ftplugin/tex_macros.vim.
The documentation mentions that you should use a file in ftplugin after the filetype you use. Check :set ft? to confirm yours is indeed tex, in which case you can use tex.vim, tex_something.vim (like the suggested tex_macros.vim) or tex/something.vim (a subdirectory.)

Related

vim snippet default snippet file issue

I installed Vundle, got the snippetMate running. But when vim launched, the snippet it loaded is _.snippets. With my Understanding, it is the default for snippet. However, i want to use other snippet such as sh.snippets and tex.snippets. I try to run the SnippetMateOpenFile in Vim to locate the snippets file It doesn't appear. I checked and see that all of the snippet file is there.
Yes, the _.snippets contains the global snippets. In order to use the other ones, the correct filetype has to be set. The snippet plugin reuses the same mechanism that Vim uses for syntax highlighting and settings (like indent) that are specific to a certain programming language. Usually, filetype detection works automatically; you can check with
:verbose setlocal filetype?
This needs to print sh for shell scripts, to use sh.snippets. If it doesn't, you have to fix / enable filetype detection (see :help filetype-detect), or, for a one-time fix, set it manually:
:setf sh
(I'm not sure about your particular snippet plugin; I guess it's snipMate, but there are multiple variants around.)
I found out what happened. the snippets won't recognize the snippet files rightaway. So i saved and exit the text and reopen vim again. It works, yet seems like there must be a certain tag in order for vim to recognize the format of the file.

Change recognized filetype of a plugin

I want to use 'plasticboy/vim-markdown' and 'nelstrom/vim-markdown-folding.' They require filetype=mkd and filetype-markdown, respectively. Is there a typical way to tell a plugin to recognize a certain filetype?
I've tried changing references of mkd to markdown in the former and markdown to mkd in the latter but that hasn't had any effect. As of now, I can only use one of the plugins because they require different filetypes.
The generic names for the filetype plugins are (:help ftplugin-name):
ftplugin/<filetype>.vim
ftplugin/<filetype>_<name>.vim
ftplugin/<filetype>/<name>.vim
Therefore, you need to rename the file names themselves (possibly in addition to the contents in the file, though there shouldn't be that many). Since that makes upgrading more difficult, you can also write linker scripts, e.g. ~/.vim/ftplugin/mkd_fold.vim which just contains the following command:
:runtime! ftplugin/markdown_fold.vim

vim-cucumber doesn't find definitions

I'm trying to switch to Vim from Sublime. I do a lot of Cucumber work. A Sublime plugin allows me to jump from the step in feature file to the corresponding step definition. It looks like vim-cucumber is designed for that purpose as well. I've installed vim-cucumber using Vundle. However, when I use any of the commands in the vim-cucumber readme (e.g. [<C-d> or <C-W>d) I always get E388: Couldn't find definition. Is there some prior command or configuration I need to run to load the existing definitions for vim-cucumber to work?
The mappings used by that plugin override buit-in mappings that do more or less the same thing (but not for cucumber so that's alright).
The error message you get is associated with those buit-in mappings (:help e388) so it looks like the buit-in mappings are not overriden and thus that your plugin is not installed correctly.
romani, thanks for pointing me in the right direction. To fix the issue:
I removed vim-cucumber from my Vundle plugin list in .vimrc
executed :PluginClean
removed some references to cucumber.vim in my .vim directory that I think I added either via pathogen or manually at some point
added the plugin back in to .vimrc
executed :PluginInstall
Looks like jumping to definitions is working. Thanks.

How can I reload a VIM plugin after VIM was started?

I am modifying an installed VIM plugin and in another Terminal tab I am testing the results.
Each time I want to test the changes I have to restart VIM.
Is there any faster way to do this process? How can I reload a VIM plugin after VIM was started?
The plugin is installed via Vundle
I have tried to run :so % that is supposed to reload the .vimrc file but I still cannot see my changes.
If there weren't an inclusion guard (if ! exists('g:loaded_pluginname') ...), you could simply :runtime! plugin/pluginname.vim (or :source % if it's currently opened) and all plugin definitions would be re-read.
But as most plugins (correctly) use such a guard, you need to :unlet that variable first:
:unlet g:loaded_pluginname | runtime! plugin/pluginname.vim
My ReloadScript plugin can do this with one command if the guard name adheres to the canonical naming, and the scriptease plugin has such a command, too.
Edit: Some plugins use differently named guard variables, or other ways that prevent reloading. The plugins from mattn (like emmet.vim) are quite elaborate; maybe there's some special mechanism; I don't use that plugin. You could ask the author for advice, though.

Latex and Vim usage

How can I use Latex effectively in VIM?
Is there a way to configure compile errors by highlighting the line in vim?
I have syntax highlight. What are other recommended add-ons? Is a makefile the recommended way to compile a latex file to pdf?
TexWorks lets you open and replace the opened pdf everytime it's recompiled. Is there a plugin to do something similar in vim?
I've just begun playing around with LaTeX-Box. It seems like a good plugin. I, also used VIM-LaTeX for a while, but I didn't really like the key mappings, and it seemed a bit to heavyweight as Jeet described.
I like LaTeX-Box so far because it used latexmk to compile, which is what I was using anyway. Latexmk will sit in the background and watch your .tex file for changes, and then automatically compile for you. And if you use a pdf viewer which refreshed changes (such as evince on Linux) you can see updates every time you change. Adding
let g:LatexBox_latexmk_options = "-pvc -pdfps"
to my .vimrc got latexmk working properly. You also need the latexmk script somewhere on you PATH. The key mapping to start latexmk is the same as Vim-Latex's compile: '\ll' (that's lowercase LL).
I also use SuperTab plugin for completions, which is great. And I took the dictionary files from Vim-LaTeX so I have a ton of auto completion words to use. This dictionary file is: ftplugin/latex-suite/dictionaries/dictionary in the vim-latex files. What I did was copy this file into ~/.vim/dictionaries/ and renamed it 'tex' then I added these lines to my .vimrc file:
set filetype on
au FileType * exec("setlocal dictionary+=".$HOME."/.vim/dictionaries/".expand('<amatch>'))
set complete+=k
Then if I type the beginning of a latex command and hit 'tab' I will get a list of completions. Pretty handy. BTW that 'au' command in the vimrc will also load dictionaries for any other filetypes if you want. A useful trick.
check out vim latex
If you use vim latex put the following in your .vimrc:
let g:Tex_DefaultTargetFormat='pdf'
and it should compile to pdf by default. (I think the default compilation key
is \ll).
You can also check AutomaticLatexPlugin, it has many nice features (see the features list).
Its main point is to compile the document in the background using autocommands, so that you are free from compilation cycle. This works nicely on Linux and MacOs. It contains (extended version of) Latex-Box.
vim-latex is great. But I found it too heavyweight for my tastes. I prefer more of a "Vim with LaTeX compile & view" approach, rather than "A LaTeX IDE with Vim key-bindings". So I rolled my own: 'TeX-PDF: Lightweight "stay-out-of-your-way" TeX-to-PDF development support'.
Also check out: "LaTeX Help : Help for LaTeX in vim.help format" for calling up help of LaTeX from within Vim.
I personally can get by on:
autocmd BufNewFile,BufRead *.tex set makeprg=pdflatex\ %\ &&\ open\ %:r.pdf
where open is Mac OS X specific. Linux users will want a different command to view their compiled file after running make. This works best if you have mapped a key to write and then run make (and you should - once you have single key save and compile, you'll never go back).

Resources