20120522

Vi: dividir la pantalla - Vi: split the window

Si vosotros sois también de esos chalaos que disfrutáis con el uso de Vi seguro este tip os será de utilidad. Si queremos dividir la pantalla de edición para editar otro archivo, o situarnos en dos puntos distintos del mismo archivo, sólo tenemos que teclear en modo comando lo siguiente:
:split

Con esto conseguiremos dividir la pantalla horizontalmente. Si lo que queremos es dividirla en vertical, teclearemos:
:vsplit

Complejo, eh!
Podemos ejecutar estas órdenes, combinándolas, tantas veces como queramos (no se si tiene límite) dividiendo una y otra vez la pantalla.

Si queremos abrir otro archivo, añadimos la ruta de este:
:split file_path
:vsplit file_path

O si lo que queremos es dividirla creando un archivo nuevo, añadiremos una n:
:split n
:vsplit n

Siempre y cuando no exista un fichero de nombre n en nuestro directorio de trabajo.
Para navegar entre las diferentes divisiones creadas, podemos utilizar:
CTRL+W W para pasar de una sección a otra hacia adelante.
CTRL+W tecla de dirección para pasar al siguiente marco en esa dirección. Podemos usar tanto las flechas como hjkl

También podemos redimensionar cada sección pulsando:
n CRTL+W + que hará crecer la sección en n líneas
n CRTL+W - que reducirá la sección en n líneas

Para cerrar cada una de ellas, como siempre :q :qw :x, etc.
Y esto es sólo el principio. Que lo disfrutéis.
:qw


If you are on of those geeks who enjoy typing and text editing with Vi I'm sure you'll find the following tip as useful as me.
You can split the the editor window typing the following while you're in command mode:
:split

To split it vertically, just type:
:vsplit

As easy as that! And we can repeat this command as many times as we like.

We can open other file on a new window typing:
:split file_path
:vsplit file_path

To create a new empty window:
:split n
:vsplit n

If there is a file called n on the working dvimirectory the previous command will open it instead of a new one :p
To navigate between the diferent divisions, we could type:
CTRL+W W to go forward to the next division
CTRL+W arroy key or khjkl to switch between windows on any direction.

We can algo change the window size typing:
n CRTL+W + qwhich will make the window grow n lines
n CRTL+W - which will srink the window n lines

And finally to close them,  :q :qw :x, etc.
This is just a piece of everything we can do with Vi. Enjoy it.
:qw

PS. I know, I know. My English is not good enought but, the more you help me, the more I learn.