Tuesday, July 7, 2009
Close all windows in vimdiff - vi tip
vimdiff
a powerful file comparison tool (edit two or three versions of a file with Vim and show differences)
Two important window commands to close windows while performing vimdiff on multiple files. (Also applicable when you open multiple files using :split or :vsplit)
ctrl-w c - Close this window
ctrl-w o - close all Other windows (mnemonic - Only)
Two of vimdiff important commands:
do - (diff-obtain) obtain differences from other window into this one
dp - (diff-put) push differences in current window to the other window
Labels:
Bash,
bash shell newbie,
vi editor tips,
vi handy commands,
VIM,
vimdiff
Subscribe to:
Post Comments (Atom)
© Jadu Saikia www.UNIXCL.com
6 comments:
Undo your changes even after quitting the vim editor.
Scenario:
---------
As all of us know that if you write and quit vim editor, the changes are permanent and you cannot get the old changes back.
Requirement:
------------
For some reason, we badly want the previous changes back.
Solution:
---------
With vim v7.3, we can get the old changes back even after the quitting the editor.
So what to do?
------------------
Before editing the file, execute the following commands in vim normal mode
:set undofile
:set undodir=/tmp
that's it.!
In order to make this change as
permanent, do the following..
Create a file called ".exrc" or ".vimrc" file in $HOME directory. In my case it is /root. Dump the above commands without ":" like this into the .exrc or .vimrc.
set undofile
set undodir=/tmp
Save the file. From now onwards, undo history is maintained in background.
How to work with it?
---------------------------
Just hit "u" key to undo the changes just like the way when the file is not closed.
Where can i get the latest version?
-----------------------------------ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
Happy vimming...!
@Adithya Kiran, this is really a cool tip. Thanks.
Your blog is really nice one Jadu, Thanks a lot for accepting my tips onto your blog.:)
Hi Jadu, Here's one more cool vim tip.
Tip:
Capture a shell command output directly on to working buffer.
How?:
:.!sh
Example:
# vim sample.txt
cat /proc/cpuinfo
Now, keep cursor on the required line and type the below command.
:.!sh
that's it..! the command output is available on the buffer.
Corollary:
You can write 4-5 commands and select visually, and type :'<,'>!sh
for a group of commands
happy vimming..!
Jadu,
With the below two tips, you can speed up your search for patterns in vim editor
In general, to search for a pattern like "kernel-headers-2.6.35.6-45.fc14.i686" in vim editor, we need to type the whole string (or) select the string using mouse, then / does the task. But there is one other way to accomplish the same task (using key board).
1. Place the cursor over the the string to be searched.
2. Type / (i.e / followed by ctrl+r followed by ctrl+a)
Corollary: / will place the word under cursor.
@Adithya, thanks a ton. All your tips are really useful, much appreciated. Thanks again.
Post a Comment