logo Debian Debian Debian-France Debian-Facile Debian-fr.org Forum-Debian.fr Debian ? Communautés logo inclusivité

Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).


L'icône rouge permet de télécharger chaque page du wiki visitée au format PDF et la grise au format ODT → ODT PDF Export

Ceci est une ancienne révision du document !


Vim IDE python

Installer VIM IDE pour python

Prérequis

  • Pour utiliser vim avec python3
apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
    libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
    libcairo2-dev libx11-dev libxpm-dev libxt-dev python-dev \
    ruby-dev mercurial

On supprime les versions vim existantes sur le système

  • En effet,
vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 31 2015 23:36:07)
Rustines incluses : 1-488, 576
Modifié par pkg-vim-maintainers@lists.alioth.debian.org
Compilé par jamessan@debian.org
Énorme version avec interface graphique GTK2.
  Fonctionnalités incluses (+) ou non (-) :
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     +tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace

+python -python3 :-/

apt-get remove vim vim-runtime gvim vim-tiny vim-common vim-gui-common

On récupère vim à la source et on le compile avec l'option python3

cd ~
hg clone https://code.google.com/p/vim/
cd vim
./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp \
            --enable-python3interp vi_cv_path_python3=/usr/bin/python3.4 \
            --with-python-config-dir=/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu  \
            --enable-perlinterp \
            --enable-luainterp \
            --enable-gui=gtk2 --enable-cscope --prefix=/usr
make VIMRUNTIMEDIR=/usr/share/vim/vim74
apt-get install checkinstall
checkinstall
**********************************************************************
 
 Done. The new package has been installed and saved to
 
 /root/vim/vim_20151209-1_amd64.deb
 
 You can remove it from your system anytime using: 
 
      dpkg -r vim
 
**********************************************************************
Et maintenant vim –version retourne -python +python3 8-)

On fait de vim son éditeur par défaut

update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1
update-alternatives --set editor /usr/bin/vim
update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1
update-alternatives --set vi /usr/bin/vim

Configurer vim

  • On télécharge ce script
configVim.sh
#!/bin/sh
 
mkdir -p ~/.vim/autoload/ ~/.vim/bundle/ ~/.vim/colors/ ~/.vim/ftplugin/
printf "les dossiers ~/.vim/autoload/ ~/.vim/bundle/ ~/.vim/colors/ ~/.vim/ftplugin/ ont bien été créés\n"
ls -la ~/.vim/
cd ~/.vim/autoload
wget https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
cd ~/.vim/bundle
git clone https://github.com/tpope/vim-sensible.git && git clone https://github.com/kien/ctrlp.vim.git && git clone https://github.com/scrooloose/nerdtree && git clone https://github.com/klen/python-mode.git && git clone https://github.com/Lokaltog/vim-powerline.git && git clone https://github.com/jistr/vim-nerdtree-tabs.git
cd ~/.vim/colors
wget https://raw.githubusercontent.com/thesheff17/youtube/master/vim/wombat256mod.vim
cd ~/.vim/ftplugin
wget https://raw.githubusercontent.com/thesheff17/youtube/master/vim/python_editing.vim
cd ~
wget https://raw.githubusercontent.com/thesheff17/youtube/master/vim/vimrc
ls -la ~/vimrc
printf "Le fichier ~/vimrc a bien été reçu.\n"
mv vimrc ~/.vimrc
printf "Le fichier ~/vimrc est dans ~/.vimrc\n"
printf "Et voilà !\n"
  • On installe cette configuration
mv ~/Téléchargements/configVim.sh ~/
chmod +x configVim.sh
./configVim.sh
Pour la supprimer, c'est simple :
rm -rf ~/.vim/ && rm -r ~/.vimrc
  • Pour avoir la même configuration quand on lance vim en root
cd ~
wget https://raw.githubusercontent.com/thesheff17/youtube/master/vim/vim.py
chmod +x ./vim.py
./vim.py -u root
Et pour supprimer cette configuration de vim utiliser en tant que root :
cd ~ && rm -rf ~/.vim/ && rm -r ~/.vimrc

Utilisations

Configurer Vim pour Python

  • On installe curl
apt-get install curl
  • On installe git :
apt-get install git-core
  • On installe pathogen

Voir : https://github.com/search?utf8=%E2%9C%93&q=pathogen

mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
  • On crée et édite un fichier caché ~/.vimrc :
vim ~/.vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on

pathogen va chercher dans le répertoire bundle les plugin qu'on lui a installé et les utiliser comme si on les avait installé dans le fichier .vimrc

  • On installe le module nerdtree :

Voir : https://github.com/scrooloose/nerdtree

git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
Principales commandes de NERD Tree :
  t: Ouvrir le fichier sélectionné dans un nouvel onglet
  i: Ouvrez le fichier sélectionné dans une fenêtre fissure verticale
  s: Open the selected file in a vertical split window
  I: Commutation de fichiers cachés
  m: Pour faire apparaître un menu qui vous permettra d'ajouter rapidement, déplacer(=renomer), copier et supprimer des nœuds (ou fichiers).
  R: Actualiser l'arbre, utile si les fichiers ont changés en dehors de Vim
  ?: Commutation entre l'aide rapide et l'explorateur NERD Tree 
  Ctrl +w puis w: Passer de l'explorateur NERD Tree à la fenêtre d'édition des fichiers
  • On installe vim-airLine améliorer le statusline.
git clone https://github.com/bling/vim-airline.git ~/.vim/bundle/vim-airline

On ajoute la ligne suivante dans ~./vimrc :

let g:airline#extensions#tabline#enabled = 1
  • Après avoir ouvert plusieurs fichiers, pour passer d'un fichier à l'autre, le curseur entant placé dans l'encadré d'édition d'un fichier:
  1. On peut utiliser la commande vim :register puis on choisit son buffer ;
  2. On peut faire :bn (pour Buffer Next) ou :bp (pour Buffer Prevous) ;
  • On peut se faire un racourcit :
  1. On édite ~/.vimrc
  2. on ajoute :
nmap <C-n> :bn<CR>
nmap <C-p> :bp<CR>
  • Pour utiliser la souris
set mouse=a
  • Utilisation de la souris pour naviger entre les fenêtres, et sélectionner dans une seule fenêtre (i.e mode visuel de vim)

On édite ~/.vimrc

On ajoute :

set mouse=a
  • On ajoute le plugin syntastic

Voir : https://github.com/scrooloose/syntastic

git clone https://github.com/scrooloose/syntastic.git ~/.vim/bundle/syntastic
  • On ajoute le plugin tagbar
git clone https://github.com/majutsushi/tagbar.git ~/.vim/bundle/tagbar
Ajout dans ~/.vimrc
"Racourci clavier pour basculer avec Tagbar
nmap <F2> :TagbarToggle<CR>
  • Ajout de l'autocomplétion :
Ajout dans ~/.vimrc
"Pour utiliser un plugin d'autocomplétion
set omnifunc=syntaxComplet#Complete

VIM IDE DJANGO

utilisateurs/hypathie/tutos/vim-ide-python.1449698940.txt.gz · Dernière modification: 09/12/2015 23:09 par Hypathie

Pied de page des forums

Propulsé par FluxBB