Plantilles en vim
Fa unes setmanes vaig llegir un interessant article penjat en Bulma.net sobre com tenir plantilles en vim.
Interessant perquè vim s’està convertint, a poc a poc, en l’editor predeterminat que vaig emprant per a programar en Python, deixant de banda altres editors més visuals però menys pràctics. Interessant perquè tots sabem com de molest és haver d’escriure sempre el mateix (capçalera, estructura, funcions predeterminades,…) en crear un nou fitxer.
No cal afegir res més a l’explicació que fa aaloy a l’apunt. Tan sols dir que si no creem el directori .vim al nostre home, no podrem instal.lar el plugin perquè ens donarà un error.
Una vegada instal.lat tan sols cal crear un fitxer de nom python a la carpeta ~/.vim/templates. Així cada vegada que obrim creem un nou fitxer amb extensió *.py se’ns obrirà la plantilla, i no haurem d’escriure sempre el mateix.
Ací us penge el meu:
#/usr/bin/env python
# -*- coding: utf-8 -*-
##-----------------------------------------------------------------------##
## *******.py Un programa per
##
##
## Copyright (C) 2006 Vicent Cubells i Peña
## All Rights Reserved.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING.
## If not, write to the Free Software Foundation, Inc.,
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
## Vicent Cubells i Peña
##
## http://www.vcubells.net
##
##———————————————————————–##
import pygtk
pygtk.require(’2.0′)
import gtk
def main():
gtk.main()
return 0
if __name__ == “__main__”:
main()
# cursor: 5 del