Vim: Inserting output of unix/linux command
I had seen other vim experts do this but couldn’t remember how they did. Today I finally search and found how to insert the output of a unix/linux command directly in a vim buffer(without copy-pasting).
:r!ls /home/
or in the visual mode (by pressing V) simply !ls /home/
Simple isn’t it and quite useful at times.
Vim: Delete every line in the file that does not match a pattern
I realized the power of :g much later than many other commands in vim and I think this one has been there even in vi for a long time.
Here is a great tip that covers the virtues of :g in vim:
The reason I ended up with this tip was that I needed to find a simple command that would delete all lines matching a pattern.
I knew how to delete all lines that matched a pattern.
:g/pattern/d
but I was looking for the inverse and I found it :g’s cousin :v in the above tip as a user comment.
:v/patter/d
did the job very well. Once again vim saved the day. ![]()
Vim: Turn off gVim toolbar
I don’t know about you but I don’t like my gVim real estate to be polluted by toolbar under the menus so in my early days of using gVim I researched and discovered a way to turn them off.
Here is what you need to put in your .gvimrc (or _gvimrc on windows):
" To set the toolbars off (icons on top of the screen)set guioptions-=T
Vim: Setting height and width of gVim window
I always struggled with this on my windows Vim and today I saw the fix on a vim users mailing list addressing this exact question.
Here is the way to set height (lines) of gVim (graphical Vim) window:
:set lines=40
and here is how to set width (columns) of gVim windows:
:set columns=80