In order to insert output of a command while in Vim
editor. Just give following command.
:r !any_command
Replace any_commandwith the command you want to use.
22
23
Suppose we want insert date at line number 23,
goto line number 23, by pressingG23
Then type following command
:r !date
22
23 Sat May 9 20:15:56 IST 2009
Saturday, May 9, 2009
Read Command Output in Vim
Thursday, March 26, 2009
Undoing All Changes Made in a File
The command:
:e!
undoes all the changes made to the file.
I hope this command will save you sometime,
if you made many disastrous changes.
:e!
undoes all the changes made to the file.
I hope this command will save you sometime,
if you made many disastrous changes.
Tuesday, February 17, 2009
Going to Line Number
There are two ways for going to a line (say line number 149).
(i) Esc :149
(ii) Press 149G
PS: I would like to suggest that please enable the line number by pressing
Esc :set nu
in the Vim editor. Then you can use above trick efficiently and easily.
(i) Esc :149
(ii) Press 149G
PS: I would like to suggest that please enable the line number by pressing
Esc :set nu
in the Vim editor. Then you can use above trick efficiently and easily.
Wednesday, November 26, 2008
Auto Completion of Word in Vim
If you want to auto complete a word(or variable in a program), then just press Ctrl-P in the editing mode.
For example:
com<ctrl-p> => complete.
If there is more than one possible words for completion, then vim shows a drop down list, from where you can select the desired word.
Friday, October 17, 2008
Pasting in Vim without Formatting
If smartindent, autoindent, and/or cindent are enabled in VIM,
you find that pasting in the vim does a lot right indentation, which
is not desirable always.
Therefore, you may want to disable indentation while pasting.
This can be done as:
:set paste
Paste your buffer content in the VIM. Then revert back
to indentation mode as given below:
:set nopaste
I hope that this tip will help you in saving time and reducing key
presses.
Enjoy VIMming :)
you find that pasting in the vim does a lot right indentation, which
is not desirable always.
Therefore, you may want to disable indentation while pasting.
This can be done as:
:set paste
Paste your buffer content in the VIM. Then revert back
to indentation mode as given below:
:set nopaste
I hope that this tip will help you in saving time and reducing key
presses.
Enjoy VIMming :)
Thursday, August 21, 2008
Using VIM Command in BASH Command Line
You can use vim commands in the BASH
command line editing, like
line in your bashrc file ~/.bashrc. Just type the command given
below:
$ echo 'set -o vi' >> ~/.bashrc
$ . ~/.bashrc
Now, you can use vim commands by pressing Esc (Escape)
button.
command line editing, like
- moving cursors, using l ;
- Changing word, using cw
- etc
line in your bashrc file ~/.bashrc. Just type the command given
below:
$ echo 'set -o vi' >> ~/.bashrc
$ . ~/.bashrc
Now, you can use vim commands by pressing Esc (Escape)
button.
Tuesday, July 1, 2008
Sorting a Column in Vim
I am also learning the Visual mode in Vim.
If you want to sort a column (usually selected)
in a file.
$ vim unsorted.txt
2
3
1
5
4
Go to the line, from where you want to start
the sort. Press Ctrl-v, now select the column
using arrow keys.
2
3
1
5
4
Now, press :sort in command mode. You will get
1
2
3
4
5
If you want to sort a column (usually selected)
in a file.
$ vim unsorted.txt
2
3
1
5
4
Go to the line, from where you want to start
the sort. Press Ctrl-v, now select the column
using arrow keys.
2
3
1
5
4
Now, press :sort in command mode. You will get
1
2
3
4
5
Subscribe to:
Posts (Atom)
