Tag: vi

vim mappings – easy way to do things.

You can use vim mappings to make some of your editor tasks very simple. Here I am giving you just a example, but you could always let your imagination run wild.

:nmap ,b Oj0c$**hP

And what do we do here.

O – Add a new line

– Go to normal mode

j – go to newly added line

0 – Go to begining of line

c$ – Change till end of line

****<Esc> РEnter  four stars

h – go back one character.

P –¬† Paste the last deleted line, which is what we deleted with c$.

This is just to show you how powerful, mappings can be. So, GO WILD with imagination.

 

Enhanced by Zemanta

vim – yank/xopy in different register to paste

Very quick update, to use registers, you can select and then yank in a register to paste using the same register. This could be a convinient way to copy multiple selections and then paste which ever selection you want. Here is the simple way to do it:

visuallly select with v/V

then “qy to yank (here we are yanking into register q, so in the command you can use any of a-z to use as register)

then “qp to paste..

To, view all the registers, you can use the command “registers”.

 

Enhanced by Zemanta

bash – using the vi mode more effectively.

Vi blogging bundle
Vi blogging bundle (Photo credit: pedro mg)

You can first set the bash mode to vi. This will enable some vim like features to bash. So, add this to .bashrc :

set -o vi

Once, you have done that then its time to get more out of the vi mode. First, check some things and set some interesting stuff.

#Display all the bindings :
bind -P

#Copy the current bindings and use it in inputrc:
bind -p |grep -v self-insert>~/.inputrc

In the inputrc, so generated, all the functions and macros not bound are commented with “#” and you can set them to your choice as in other examples.

And here is a link that can get you started.

http://www.catonmat.net/blog/bash-vi-editing-mode-cheat-sheet/

 

Enhanced by Zemanta