Vim (Vi IMproved) è un famoso editor di testo che può essere utilizzato per editare testo di ogni genere: tipicamente si utilizza per il codice C/C++, PHP, Python, Perl ed altri ancora. In ambiente SSH può essere utile per modificare i file di configurazione del vostro VPS, fermo restando che esistono editor più semplici da sfruttare (come ad esempio pico): in questo nuovo articolo andremo a vedere come si possa installare Vim.
Anzitutto andiamo a fare login sul nostro VPS (o server dedicato, a seconda dei casi) in questo modo:
ssh nomeu@IP
Ci verrà richiesta la password dell’utente nome, la inseriamo e dopo qualche istante dovremmo avere accesso alla macchina remota. Andiamo ora ad installare, da console remota e dopo aver fatto correttamente login, il file del programma con il seguente comando:
apt-get install vim
L’output generato sarà il seguente:
Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: bind9utils Use 'apt-get autoremove' to remove them. The following extra packages will be installed: libgpm2 libpython2.7 vim-runtime Suggested packages: gpm ctags vim-doc vim-scripts The following NEW packages will be installed: libgpm2 libpython2.7 vim vim-runtime 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 8,530 kB of archives. After this operation, 28.1 MB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://mirrors.service.networklayer.com/ubuntu/ precise/main libgpm2 amd64 1.20.4-4 [17.2 kB] Get:2 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main libpython2.7 amd64 2.7.3-0ubuntu3.1 [1,188 kB] Get:3 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main vim-runtime all 2:7.3.429-2ubuntu2.1 [6,277 kB] Get:4 http://mirrors.service.networklayer.com/ubuntu/ precise-updates/main vim amd64 2:7.3.429-2ubuntu2.1 [1,048 kB] Fetched 8,530 kB in 1s (8,515 kB/s) Selecting previously unselected package libgpm2. (Reading database ... 57205 files and directories currently installed.) Unpacking libgpm2 (from .../libgpm2_1.20.4-4_amd64.deb) ... Selecting previously unselected package libpython2.7. Unpacking libpython2.7 (from .../libpython2.7_2.7.3-0ubuntu3.1_amd64.deb) ... Selecting previously unselected package vim-runtime. Unpacking vim-runtime (from .../vim-runtime_2%3a7.3.429-2ubuntu2.1_all.deb) ... Adding 'diversion of /usr/share/vim/vim73/doc/help.txt to /usr/share/vim/vim73/doc/help.txt.vim-tiny by vim-runtime' Adding 'diversion of /usr/share/vim/vim73/doc/tags to /usr/share/vim/vim73/doc/tags.vim-tiny by vim-runtime' Selecting previously unselected package vim. Unpacking vim (from .../vim_2%3a7.3.429-2ubuntu2.1_amd64.deb) ... Processing triggers for man-db ... Setting up libgpm2 (1.20.4-4) ... Setting up libpython2.7 (2.7.3-0ubuntu3.1) ... Setting up vim-runtime (2:7.3.429-2ubuntu2.1) ... Processing /usr/share/vim/addons/doc Setting up vim (2:7.3.429-2ubuntu2.1) ... update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode. update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode. Processing triggers for libc-bin ... ldconfig deferred processing now taking place
In caso abbiate invece già installato il software comparirà invece una notifica del genere (e non sarà necessario fare nulla, la cosa è da considerarsi normale):
Reading package lists... Done Building dependency tree Reading state information... Done vim is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and ... not upgraded.
A questo punto possiamo editare i nostri file con Vim, ad esempio:
vim nomefile.php
Attenzione: prima di utilizzare il programma è bene familiarizzare con la sua interfaccia (vedi guida).