Luc Hermitte's VIM File Type Plugins | Monday 22nd November 2004 |
Here is the main section of my VIM pages : the one exposing my ftplugins.
You don't know what ftplugins are, you can ask VIM for what they
are : :h ftplugin
.
In short : they are VIM scripts that are loaded (sourced by VIM) only when
we edit a file of a specific (file)type. So, C++ special settings won't
get loaded when editing a LaTeX file, and vice versa.
To my opinion, they are one of the major new feature in the version 6 of
VIM. They enable us to have a clean and as complete configuration as we
wish for. They are the welcomed death of unmaintanale .vimrc
s
-- no more autocommands used to detect filetypes and define mappings,
settings, load files, etc. in consequence. It become transparent.
I don't known where to start ... Let's say that when you insert a parenthesis, a bracket, a quote or anything like that, you may wish you have not to worry about the corresponding closing character. The two following files are dedicated to the management of this problem.
Note: As they are plugins, they are meant to be placed into one of your
{runtimepath}/plugin/
directories.
bracketing.base.vim <raw file> |
A first solution has been proposed by Stephen Riehm. You could
find the whole package with an important documentation and
other remarks on Benji
Fisher's homepage.
Stephen Riehm introduces several language-independant mappings
to manage brackets-like characters. He also introduces two
interesting global mappings : !mark! and
!jump! . They are used to mark (with text markers)
positions within the file edited and jump to them.
As I do not expect the same things from a bracketing system
when I am developing in C++ or writing LaTeX documents, I have
conducted a little modification on the original system. I
added the possibility to dynamically change the text
markers used -- I have also added some other features :
BTW, I map imap <C-J> <Plug>MarkersJumpF map <C-J> <Plug>MarkersJumpF imap <C-K> <Plug>MarkersJumpB map <C-K> <Plug>MarkersJumpB imap <C-<> <Plug>MarkersMark vmap <C-<> <Plug>MarkersMark
Requires : VIM 6.0+, and
|
|||||||||||||||||||
common_brackets.vim <raw file> |
This file eases the insertion of brackets pairs.
It is used by quite all my consequent ftplugins.
Through a set of (boolean) buffer-relative options -- cf. the implementation and the different other language ftplugins -- , it enables and configures bracketing mappings. The bracket-like pairs supported are :
b:cb_ are set
to 1. These options are not meant to be changed dynamically,
but to be set once within ftplugins.
Some behaviors can be tuned much more finely with callback
functions :
How it worksWhen we hit (in insert mode) the starting character of a pair, the second one is automatically inserted. In visual (resp. normal) mode the opening character can be hit once -- except for quotes and dollars that have to be hit twice -- in order to insert the pair around the visual area (resp. current word).
Pressing the second character from the pair puts the cursor
just after the next occurrence of this character (and in insert
mode). But you'd better use
Dynamic (de-)activationWhenTriggers.vim is
installed, the macros defined here can be activated and
deactivated as a whole by pressing <F9> .
In insert-mode, two operating modes are provided : one very
classic and one that takes advantage of my variation of Stephen
Riehm's markers when the buffer relative option AccessibilityFor personal and technical (the meta-mappings do not suit to the layout of my French keyboard) reasons, I prefer to use the opening character of a bracket-like structure in order to insert the whole structure.
In insert and normal modes, it is also possible to hit
Brackets Manipulations
I have stolen some functions from
<M-b> ) that makes VIM enter a
brackets manipulation mode (much like <CTRL-X> ). From there, you
can hit 'x ', '<delete> ', '( ',
'[ ', '{ ', or '<F1> ' that will behave like
exposed earlier, or display a little help message.
If you don't want of this brackets manipulation mode, in your
Again, if you don't like the default keybinding, with vim 6.0+
you can change them into your noremap <silent> <C-L>b :call BracketsManipMode("\<C-L>b")<cr>if g:cb_want_mode is
left to 1, otherwise define : map <C-L>bx <Plug>DeleteBrackets map <C-L>b<del> <Plug>DeleteBrackets map <C-L>b( <Plug>ChangeToRoundBrackets map <C-L>b[ <Plug>ChangeToSquareBrackets map <C-L>b{ <Plug>ChangeToCurlyBrackets map <C-L>b\ <Plug>ToggleBackslash DependenciesRequires VIM 6.0+bracketing.base.vim ,
misc_map.vim , and
Triggers.vim (facultative).
Prefer to download them with bracketing.base.vim and
their documentation as a single tarball archive:
lh-map-tools.tar.gz and
|
|||||||||||||||||||
lh-map-tools.tar.gz
|
The two previous scripts archived with
misc_map.vim and
their documentation.
|
|||||||||||||||||||
lh-map-tools.txt | The VIM documentation associated to the tarball archive. |
vim_set.vim <raw file> help on : <C-F1> |
Some macros useful for editing .vimrc and other
VIM files. Beware, several are contextual. Requires VIM 6.0+, help.vim (facultative),
misc_map.vim , and
menu-map.vim .
|
asx_set.vim <raw file> |
Two little mappings to create .asx files.
Suppose that you have several movies named foo* in
your current folder. To create an ASX file, invokes gvim
foo.asx , and within VIM, enter
=dir and then =fin . Delete the
undesired entries, save and exit.
|
Back to the VIM Page | hermitte at free.fr |