Ivsb2

De Vim-fr.

<source lang="vim"> """""""""""""""""""""""""""""""" " Début de la personnalisation " " " " http://ivsb2.free.fr " """""""""""""""""""""""""""""""" " Coloration syntaxique syntax on


" Résulats de recherche non-colorés set nohls

" Souris utilisable set mouse=a

" Recherche insensible à la casse set ignorecase

" Pour faire cesser ces bips ridicules. set vb

" Délai raccourcis-clavier set tm=500

" Indentation automatique set autoindent

" Sauvegarde rapide du fichier actuel map <F2> :w<CR> imap <F2> <ESC>:w<CR>

" Terminal map  :!xterm &<CR><CR> imap <S-F2> <ESC>:!xterm &<CR><CR>

" Gestionnaire de fichiers graphique " map <F2>t :!thunar & <CR><CR> " map <F2>t <ESC>:!thunar &<CR><CR>

" Formatage rapide du paragraphe courant ou de la selection " souris ou visuelle map <F6> gq} imap <F6> <ESC>gq}a vmap <F6> gq

" Mode collage, activation/désactivation set pastetoggle=<F11>

" Formatage sur une ligne seulement map <S-F6> gqj imap <S-F6> <ESC>gqj

" Insertion d'un modèle Makefile au début du fichier map ,mk :0r ~/.latex/Makefile-latex<CR>

" Fonctions pour fichiers LaTeX au BufEnter,BufNewFile *.tex exe Flatex()

" Eviter de colorer pour le plaintex au BufEnter,BufNewFile *.tex setfiletype tex

" Autre astuce possible, plus propre car dans la doc de Vim " let g:tex_flavor = "latex"

" Fonctions pour fichiers XML au BufEnter *.xml exe Fxml()

" Fonctions pour fichiers SPIP au BufEnter *.spip exe Fspip()

" Fonctions pour fichiers HTML au BufEnter *.html exe Fhtml() au BufEnter *.htm exe Fhtml()

" Fonctions pour Javascript au BufEnter *.js exe Fjs()

" Fonctions pour fichiers CSS au BufEnter *.php exe Fhtml()

" TXT en 72 de large " Prévoir fonction... au BufEnter,BufNewFile *.txt set tw=72

function! Flatex() " Codages des caractères ISO-8859-1 set fileencoding=iso-8859-1

" Types de fichiers à ignorer set wildignore=*.dvi,*.ps,*.toc,*.log,*.pdf,*.aux

" Dossier du fichier comme dossier de travail de gVim " Je ne le fais pas avec Vim mode texte. " Et je ne sais pas vraiment pourquoi... if has("gui_running") set acd endif " Pour gVim < 7.0 "if has("gui_running") " au BufEnter * :lcd %:h "map ,cwd :cd %:h

" 4 espaces me suffisent en LaTeX pour les tabulations ou indentations set ts=4 set sw=4

" Largeur de texte standard set tw=72

" Modèles map ,mod :0r ~/.latex/modele.tex<CR> map ,ex :0r ~/.latex/ex.tex<CR> map ,pre :0r ~/.latex/presentation.tex<CR>

" Lancement Xfig map <F3> :!LANG=fr_FR.iso-8859-1 xfig &<CR><CR> imap <F3> <ESC>:!LANG=fr_FR.iso-8859-1 xfig &<CR><CR>

" Lancement Inkscape map <F3>i :!inkscape &<CR><CR> imap <F3>i <ESC>:!inkscape &<CR><CR>

" Sauvegarde et compilation PDFLaTeX (-> PDF) map <F4> <ESC>:w<CR>:!pdflatex %<.tex<CR><CR> imap <F4> <ESC>:w<CR>:!pdflatex %<.tex<CR>a

" Sauvegarde et compilation LaTeX (-> DVI) set <S-F4>=�[1;2S map <S-F4> <ESC>:w<CR>:!latex %<.tex<CR><CR> imap <S-F4> <ESC>:w<CR>:!latex %<.tex<CR>a

" Visualisation PDF map <F5> :!xpdf %<.pdf &<CR> imap <F5> <ESC>:!xpdf %<.pdf &<CR>

" Visualisaton DVI map <S-F5> :!xdvi %<.dvi &<CR><CR> imap <S-F5> <ESC>:!xdvi %<.dvi &<CR><CR>a

" Conversion vers Postscript map <F7> :!dvips %<.dvi -o %<.ps <CR><CR> imap <F7> <ESC>:!dvips %<.dvi -o %<.ps <CR>

" Visualisation Postscript map <F8> :!gv %<.ps &<CR><CR> imap <F8> <ESC>:!gv %<.ps &<CR><CR>

" Réduction A4 vers double-A5 map <S-F7> :!psnup -2 %<.ps %<-miformat.ps<CR>

" Visualisation double-A5 map <S-F8> :!gv %<-miformat.ps &<CR><CR>

" Impression demi PDF map <F9> :!lpr -o number-up=2 %<.pdf

" Make PDF map <F10> :!make pdf<CR> imap <F10> <ESC>:!make pdf<CR>

" Nettoyage des fichiers map ,cln :!rm -f %<.aux %<.dvi %<.log %<.out %<.ps %<.toc %<-miformat.ps <CR> imap ,cln :!rm %<.aux %<.dvi %<.log %<.out %<.ps %<.toc %<-miformat.ps <CR>

" TeX, LaTeX imap ,tex \TeX{} imap ,la \LaTeX{}

" Euro imap ,eu \euro{}

" Insertion fraction imap ,fr \dfrac{}{}<ESC>2hi imap ,tfr \tfrac{}{}<ESC>2hi

" Taille math standard imap ,dst \displaystyle{}<ESC>i vmap ,dst s\displaystyle{<ESC>pa}

" Insertion d'une figure imap ,igr \includegraphics{}<ESC>i vmap ,igr s\includegraphics{<ESC>pa}

imap ,ppr \parpic[r]{\includegraphics{}}<ESC>hi imap ,ppl \parpic[l]{\includegraphics{}}<ESC>hi

vmap ,ppr s\parpic[r]{\includegraphics{<ESC>pa}} vmap ,ppl s\parpic[l]{\includegraphics{<ESC>pa}}

imap ,fig \begin{figure}<CR>\end{figure}<ESC>O vmap ,fig S\begin{figure}<CR>\end{figure}<ESC>P

imap ,wf \begin{wrapfigure}{}{}<CR>\end{wrapfigure}<ESC>O\includegraphics{}<ESC>i """""vmap ,wf S\begin{wrapfigure}{}{}<CR>\end{wrapfigure}<ESC>\includegraphics{}P

" Table des matières imap ,toc \tableofcontents

" (Sous-(sous-)Section numérotée imap ,s \section{}<ESC>i imap ,ss \subsection{}<ESC>i imap ,sss \subsubsection{}<ESC>i vmap ,s s\section{<ESC>pa} vmap ,ss s\subsection{<ESC>pa} vmap ,sss s\subsubsection{<ESC>pa}

" (Sous-)Section non-numérotée imap ,s* \section*{}<ESC>i imap ,ss* \subsection*{}<ESC>i imap ,sss* \subsubsection*{}<ESC>i vmap ,s* s\section*{<ESC>pa} vmap ,ss* s\subsection*{<ESC>pa} vmap ,sss* s\subsubsection*{<ESC>pa}

" Présentations LaTeX-Beamer imap ,un \uncover<><ESC>i imap ,on \only<><ESC>i imap ,fm \begin{frame}<CR>\end{frame}<ESC>O

imap ,ft \frametitle{}<ESC>i imap ,al \alert{}<ESC>i

" Marques de modifications imap ,chb \begin{changebar}<CR>\end{changebar}<ESC>O vmap ,chb S\begin{changebar}<CR>\end{changebar}<ESC>P

" Environnement quelconque imap ,env \begin{ENV}<CR>\end{ENV}<ESC>O vmap ,env S\begin{ENV}<CR>\end{ENV}<ESC>P

" Retour ou saut de ligne imap ,cr \\ <CR>

" Retour à la ligne justifié imap ,lb \linebreak

" Retour à la ligne simple imap ,nl \newline

" Saut de page imap ,pb \pagebreak

" Changement de colonne imap ,cb \columnbreak

" Gros saut de ligne imap ,bs <CR>\bigskip<CR>

" Ligatures imap ,oe \oe{}

" Mode maths en ligne imap ,$ $$<ESC>i vmap ,$ s$<ESC>pa$

" Mode maths centré imap ,$$ \[<CR>\]<ESC>O vmap ,$$ S\[<CR>\]<ESC>P

" Texte normal en mode maths imap ,rm \textrm{}<ESC>i

" Racine carrée imap ,rc \sqrt{}<ESC>i vmap ,rc s\sqrt{<ESC>pa}

" Pi imap ,pi \pi imap ,Pi \Pi

" Angles et trigo imap ,wh \widehat{}<ESC>i imap _c \cos imap _s \sin imap _t \tan

" Flèche fonction imap ,lm \longmapsto<ESC>a

" Signe multiplié imap ,* \times

" Signé divisé imap ,/ \div

" Centrage imap ,c \begin{center}<CR>\end{center}<ESC>O vmap ,c S\begin{center}<CR>\end{center}<ESC>P

" Frame imap ,frm \frame<CR>}<ESC>O vmap ,frm S\frame{<CR>}<ESC>P

" Minipage imap ,mp \begin{minipage}[t]{}<CR>\end{minipage}<ESC>O vmap ,mp S\begin{minipage}[t]{}<CR>\end{minipage}<ESC>P

" Double-colonnage imap ,dc \begin{multicols}{2}<CR>\end{multicols}<ESC>O vmap ,dc S\begin{multicols}{2}<CR>\end{multicols}<ESC>P

" Caractères machine à écrire imap ,tt \texttt{}<ESC>i vmap ,tt s\texttt{<ESC>pa}

" Caractères gras imap ,bf \textbf{}<ESC>i vmap ,bf s\textbf{}<ESC>Pi

" Paragraphe imap ,pa \paragraph{}<ESC>i vmap ,pa s\paragraph{}<ESC>Pi


" Soulignement imap ,_ \underline{}<ESC>i vmap ,_ s\underline{<ESC>pa}

" Ligne supérieure imap ,ol \overline{}<ESC>i vmap ,ol s\overline{<ESC>pa}

" Caractères penchés imap ,sl \textsl{}<ESC>i vmap ,sl s\textsl{<ESC>pa}

imap ,sls {\slshape<CR>}<ESC>O vmap ,sls S{\slshape<CR>}<ESC>P

" Caractères italiques imap ,i \textit{}<ESC>i vmap ,i s\textit{<ESC>pa}

imap ,is {\itshape<CR>}<ESC>O vmap ,is S{\itshape<CR>}<ESC>P

" Petites capitales imap ,sc \textsc{}<ESC>i vmap ,sc s\textsc{<ESC>pa}

" Caligraphiques math imap ,mc \mathscr{}<ESC>i vmap ,mc s\mathscr{<ESC>pa}

" Ensembles math imap ,mb \mathbb{}<ESC>i vmap ,mb s\mathbb{<ESC>pa}

" Ensembles imap ,bb \mathbb{}<ESC>i vmap ,bb s\mathbb{<ESC>pa}

" Verbatim imap ,vb+ \verb++<ESC>i vmap ,vb+ s\verb+<ESC>pa+

imap ,vbt \begin{verbatim}<CR>\end{verbatim}<ESC>O vmap ,vbt S\begin{verbatim}<CR>\end{verbatim}<ESC>P

" Vecteur imap ,v \overrightarrow{}<ESC>i vmap ,v s\overrightarrow{<ESC>pa}

" Logarithmes, exponentielles imap ,ln \ln{}<ESC>i imap ,exp \exp{}<ESC>i

vmap ,ln s\ln{<ESC>pa} vmap ,exp s\exp{<ESC>pa}

" Infini imap ,inf \infty{}

" Fantôme imap ,ph \phantom{}<ESC>i vmap ,ph s\phantom{<ESC>pa}

" Insertion tableau imap ,tab \begin{tabular}[t]{}<CR>\end{tabular}<ESC>k$i imap ,tabc \begin{tabular}[c]{}<CR>\end{tabular}<ESC>k$i imap ,hl \hline

imap ,ar \begin{array}[t]{rcl}<CR>\end{array}<ESC>O imap ,eqn \begin{eqnarray*}<CR>\end{eqnarray*}<ESC>O

imap ,sy \left\lbrace{}<CR>\begin{array}{rcl}<CR>\end{array}\right.<ESC>O

vmap ,tab S\begin{tabular}[t]{}<CR>\end{tabular}<ESC>P

" = en tableau math imap ,& &<SPACE>=<SPACE>&<SPACE> imap ,ou &<SPACE>\textrm{ ou }<SPACE>&<SPACE>

" Interligne tableaux imap ,ast \renewcommand{\arraystretch}{1.8}

" Accolades systèmes imap ,{ \left\lbrace{} imap ,. \right.

" Liste imap ,ite \begin{itemize}<CR>\end{itemize}<ESC>O\item<SPACE> vmap ,ite S\begin{itemize}<CR>\end{itemize}<ESC>P

imap ,it \item

" Enumeration imap ,en \begin{enumerate}[1°)]<CR>\end{enumerate}<ESC>O\item<SPACE> vmap ,en S\begin{enumerate}[1°)]<CR>\end{enumerate}<ESC>P

" Description imap ,des \begin{description}<CR>\end{description}<ESC>O\item[]<ESC>i imap ,itd \item[]<ESC>i

" Au fer à droite imap ,r \begin{flushright}<CR>\end{flushright}<ESC>O vmap ,r S\begin{flushright}<CR>\end{flushright}<ESC>P

" Au fer à gauche imap ,l \begin{flushleft}<CR>\end{flushleft}<ESC>O vmap ,l S\begin{flushleft}<CR>\end{flushleft}<ESC>P

" Alinéa imap ,ind \indent{}

" Pas d'alinéa imap ,noi \noindent{}

" Largeur de texte imap ,tw \textwidth

" Espaces supplémentaires imap ,, \, imap ,; \; imap ,q \quad imap ,qq \qquad

" Espacement horizontal ou vertical imap ,hs \hspace{}<ESC>i imap ,vs \vspace{}<ESC>i

" Remplissage horizontal ou vertical imap ,hf \hfill imap ,vf \vfill


" Parenthèses imap ,( \left( imap ,) \right) imap ,() \left( \right)<ESC>8hi

" Crochets imap ,[ \left[ imap ,] \right] imap ,dcr \left[ \right]<ESC>8hi


" Rien à droite imap ,. \right.

" Environ égal imap ,= \simeq

" Différent imap ,n= \not=

" Inégalités imap ,< \leqslant{} imap ,> \geqslant{}

" Équivalences imap ,eq \Longleftrightarrow{}

" Nombres barrés imap ,ca \cancel{}<ESC>i vmap ,ca s\cancel{}<ESC>Pa

" Boîtes imap ,fb \fbox{}<ESC>i vmap ,fb c\fbox{}<ESC>PA

" Numéros imap ,no \no{}<ESC>i imap ,No \No{}<ESC>i imap ,e \ieme{}<ESC>i imap ,er 1\ier{}

" Renvois imap ,fn \,\footnote{}<ESC>i

" Liens imap ,url \url{}<ESC>i imap ,hr \href{}{}<ESC>2hi

vmap ,url s\url{<ESC>pa} vmap ,hr s\href{<ESC>pa}{}

endfunction

function! Fhtml() " Dossier du fichier comme dossier de travail de Vim set acd " Pour Vim < 7.0 "map ,cwd :cd %:h

" Codages des caractères ISO-8859-1 "set encoding=iso-8859-1 set fileencoding=iso-8859-15

" Modèles map ,mod :r ~/site/statique/modele.html<CR>ggdd

" Sauvegarde sans quitter le mode insertion si mode insertion il y " avait. map <F2> <ESC>:w<CR> imap <F2> <ESC>:w<CR>

" Sauvegarde en quittant le mode insertion

" Visualisation map <F5> :!firefox %:p &<CR><CR> imap <F5> <ESC>:!firefox %:p &<CR><CR>a

" FTP map <F3> :!gftp &<CR><CR> imap <F3> <ESC>:!gftp &<CR><CR>a

" 4 espaces pour les tabulations suffisent en HTML set ts=4 set sw=4

" Pas de retour à la ligne set tw=0

" Insertion de saut à la ligne imap ,br <CR>
<CR>

" Headers 1, 2, 3 et 4

imap ,h1

Sommaire

<ESC>4hi vmap ,h1 s

<ESC>pa

imap ,h2

<ESC>4hi vmap ,h2 s

<ESC>pa

imap ,h3

<ESC>4hi vmap ,h3 s

<ESC>pa

imap ,h4

<ESC>4hi vmap ,h4 s

<ESC>pa

" Environnement div quelconque

imap ,div
<CR>
<ESC>?"<CR>i vmap ,div di
<CR>
<ESC>P

" Centrage

imap ,c
<CR>
<ESC>O vmap ,c S
<CR>
<ESC>P

" Justifié

imap ,j
<CR>
<ESC>O vmap ,j s
<CR>
<ESC>P

" Paragraphe

imap ,p

<CR>

<ESC>O vmap ,p S

<CR>

<ESC>P

" Gras imap ,b <ESC>8hi vmap ,b s<ESC>pa

" Italique imap ,i <ESC>4hi vmap ,i s<ESC>pa

" Image imap ,img <img src="" border="0" alt=""><ESC>19hi vmap ,img s<img src="" border="0" alt=""><ESC>19hPa

" Liens imap ,lnk <a href=""></a><ESC>5hi vmap ,lnk s<a href="<ESC>pa"><ESC>pa</a>

imap ,eml <a href="mailto:?Subject="></a><ESC>3hi vmap ,eml <a href="mailto:?Subject="><ESC>pa</a>

" Étiquettes (liens internes) imap ,lnh <a href="#"></a><ESC>5hi imap ,lnn <a name=""></a><ESC>5hi vmap ,lnn s<a name="<ESC>pa"><ESC>pa</a>

" Choix de fonte imap ,ff <ESC>8hi vmap ,ff s<ESC>pa

" Fonte courier imap ,ffc <ESC>6hi vmap ,ffc s<ESC>pa

" Taille de police imap ,fs <ESC>8hi vmap ,fs s<ESC>pa

" Taille de police 5 imap ,fs5 <ESC>6hi vmap ,fs5 s<ESC>pa

" Texte préformatté

imap ,pre
<CR>
<ESC>O vmap ,pre s
<CR>
<ESC>P

" Commentaire imap ,com <ESC>kA vmap ,com S<ESC>P

" Insertion balises de base map ,int <ESC>:r modele.html<CR>i imap ,int <ESC>:r modele.html<CR>i

" Insertion icône-titre imap ,ic <link rel="icon" type="image/png" href="favicon.ico/"> vmap ,ic s<link rel="icon" type="image/png" href=\"<ESC>pa\">

" Visualisation du fichier courant dans Mozilla " Attention : Mozilla exige le chemin absolu complet " map <F5> :w<CR>:!mozilla %:p &<CR> " imap <F5> <ESC>:w<CR>:!mozilla %:p &<CR>

" Modification du fichier courant dans Mozilla " Attention : Mozilla exige le chemin absolu complet " map <S-F5> :w<CR>:!mozilla -editor %:p &<CR> " imap <S-F5> <ESC>:w<CR>:!mozilla -editor %:p &<CR>

" Tableau

imap ,tab <CR>
<ESC>O vmap ,tab s<CR>
<ESC>P

imap ,tr <tr><cr></tr><ESC>O vmap ,tr S<tr><CR></tr><ESC>P

imap ,td <td><cr></td><ESC>O vmap ,td S<td><CR></td><ESC>P

" imap ,td <td></td><ESC>4hi " vmap ,td s<td><ESC>pa</td>

" Code imap ,co <ESC>6hi vmap ,co s<ESC>pa

" Liste (sans numérotation)

imap ,ul
    <CR>
<ESC>O vmap ,ul s
    <CR>
<ESC>P

" Liste (avec numérotation)

imap ,ol
    <CR>
<ESC>O vmap ,ol s
    <CR>
<ESC>P

" Élément de liste

imap ,li
  • <CR></li><ESC>O vmap ,li s
  • <CR></li><ESC>P " Liste descriptive " environnement imap ,dl
    <CR>
    <ESC>O vmap ,dl s
    <CR>
    <ESC>P " élément imap ,dt
    <CR></dt><ESC>O vmap ,dt s
    <CR></dt><ESC>P "description imap ,dd
    <CR></dd><ESC>O vmap ,dd s
    <CR></dd><ESC>P " Indice, exposant " imap ,ind imap ,sup <ESC>5hi " Bouton imap ,bt <form><CR></form><ESC>O<input type="button" value="Tester le bouton" onClick="alert(bouton fonctionnel);"> " Formulaire imap ,frm <form><CR></form><ESC>O " Champ de texte imap ,chp <form><CR></form><ESC>O<input type="text" value="valeur"> " evalCommand Javascript imap ,evc document.applets[0].evalCommand();<ESC>2hi " getValue Javascript imap ,gv document.applets[0].getValue();<ESC>2hi " Insertion d'un script Javascript imap ,js <script type="text/javascript"><CR></script><ESC>O " Boîte de message imap ,al alert('Alerte quelconque'); endfunction function! Fjs() " Tout de Fhtml... exe Fhtml() " ... sauf les commentaires ! vmap ,com S/*<CR>*/<ESC>P endfunction function! Fxml() set sw=2 set ts=2 " Commentaires imap ,com <ESC>hi vmap ,com S<ESC>P endfunction function! Fcss() " Tabulations réduites à 2 set ts=2 set sw=2 " Commentaires imap ,com /**/<ESC>hi vmap ,com s/*<CR>*/<ESC>P endfunction function! Fspip() "" Fortement expérimental ! "" À vos risques et périls ! " Code imap ,co <ESC>b2hi vmap ,co s<ESC>pa " Cadre de code imap ,ca <cadre><CR></cadre><ESC>O vmap ,ca S<cadre><CR></cadre><ESC>P " Intertitre imap ,itt {{{<CR>}}}<ESC>O vmap ,itt c{{{}}}<ESC>2hP " Gras imap ,bf {{}}<ESC>hi vmap ,bf c{{}}<ESC>hPI " Italique imap ,i {}<ESC>i vmap ,i c{}<ESC>PI " Ligne horizontale imap ,hr <CR>----<CR> " Lien Internet imap ,lnk [->]<ESC>2hi vmap ,lnk s[<ESC>pa-><ESC>pa] " Lien + bulle imap ,lb [->]<ESC>2hi vmap ,lb s[<ESC>pa-><ESC>pa] " Lien article "lien vers [l'article->342] "lien vers [l'article->art342] "lien vers [l'article->article 342] "Application spécifique : [->art342] (on n’a rien indiqué avant la « "flèche ») affichera automatiquement le titre de l’article 342 avec un "lien vers cet article. " Idem avec doc, img, mot, auteur, etc... " Citation imap ,qt <quote><CR></quote><ESC>O vmap ,qt S<quote><CR></quote><ESC>P endfunction </source> Ce vimrc change souvent et peut être retrouvé (fr) ici. Il peut être inclue en plus de votre vimrc en ajoutant dans votre vimrc la ligne suivante: <source lang="vim"> source <nom du fichier> </source> Remarque: :source <fichier.vim> permet de recharger un fichier vim pendant l'exécution de vim, cela marche aussi pour votre vimrc.