Vi,VIM and tmux
Still under construction
Vim tips and tricks
Command line edit with Vi
vi is your default editor with
Set vi for comamand line with
set -o vi
Esc+v, vi will open. Anything in the prompt will be ‘pasted’.
:cq to exit vi without running the current text. Otherwise will be executed.
Runing your script/program (runing the buffer…)
:!python % (where % is subtituted by the edited file)
:w | !python % This saves the file first…
:w !python Writes to STDOUT, where we run python…
:w !bash … or bash.
Here, a very deep explanation.
set nocp When invoked as "vi", vim starts in "old vi" comptible mode (withput new functionality) set [list|nolist] Shows|hidde non-printable and hidden characters:w Ctrl+g Shows filename, current line number, total lines in file, and % of file location :.= Shows current line number := Shown total number of lines
Text selection: markers…
You can get your current marks with command
m + a sets a mark, named 4, in cursor position ' + a goes to mark 'a' d + ' + a deletes from cursos to mark 'a' y + ' + a yanks from cursor to mark 'a'
Text selection: Going visual…
Text selection can be done visually:
‘v’ for character mode selection
‘V’ for line mode selection
‘Ctrl-v’ blok mode selection
Once selected, usual commands do work: ’d’, ‘y’, etc
Also, when going to the command line (’:‘), begining of block mark (“>’) and end of block mark (”>‘) will be set for you, so only replace expression has to be build.
To indent the current line, or a visual block:
ctrl-t, ctrl-d - indent current line forward, backwards (insert mode)
visual > or < - indent block by sw (repeat with . )
Working with windows
You can open multiple files, one window per file, with
vim -o <files> (horizontal windows) or
vim -O <files> (vertial windows)
Also, when inside vim,
:split <file> and
vsplit <file> opens
<file> in a new window.
Vim and tmux play very well toghether