Vim Tips Wiki
Register
(Change <tt> to <code>, perhaps also minor tweak.)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  +
{{TipNew
{{TipProposed
 
|id=0
+
|id=1655
|previous=0
+
|previous=1654
|next=0
+
|next=1656
 
|created=June 14, 2010
 
|created=June 14, 2010
 
|complexity=basic
 
|complexity=basic
Line 16: Line 16:
 
Many applications can be configured with an external pop-up editor, but require "popping up" to be the editor's default mode (for example, [[wikipedia:File Roller|File Roller]], the GNOME desktop archive editor). This is a problem when you do not have gvim installed, or when you simply prefer to use "normal" Vim from within your preferred terminal (for example, gnome-terminal).
 
Many applications can be configured with an external pop-up editor, but require "popping up" to be the editor's default mode (for example, [[wikipedia:File Roller|File Roller]], the GNOME desktop archive editor). This is a problem when you do not have gvim installed, or when you simply prefer to use "normal" Vim from within your preferred terminal (for example, gnome-terminal).
   
Create a file named <tt>vim-gnome</tt> with the following contents, and place it on your execution PATH (and use <tt>chmod&nbsp;+x&nbsp;vim-gnome</tt> to make <tt>vim-gnome</tt> executable):
+
Create a file named <code>vim-gnome</code> with the following contents, and place it on your execution PATH (and use <code>chmod +x vim-gnome</code> to make <code>vim-gnome</code> executable):
 
<syntaxhighlight lang="Bash">
 
<syntaxhighlight lang="Bash">
 
#!/bin/sh
 
#!/bin/sh
Line 23: Line 23:
 
</syntaxhighlight>
 
</syntaxhighlight>
   
This wrapper handles passing extra arguments to Vim, so you can enter things like <tt>vim-gnome&nbsp;myfile.txt&nbsp;+42</tt> to edit <tt>myfile.txt</tt> and jump to line 42.
+
This wrapper handles passing extra arguments to Vim, so you can enter things like <code>vim-gnome myfile.txt +42</code> to edit <code>myfile.txt</code> and jump to line 42.
   
Now you can use <tt>vim-gnome</tt> everywhere that you could have used <tt>gvim</tt>, or any other pop-up editor.
+
Now you can use <code>vim-gnome</code> everywhere that you could have used <code>gvim</code>, or any other pop-up editor.
  +
  +
==See also==
  +
*[[Set Vim as your default editor for Unix]]
   
 
==Comments==
 
==Comments==
  +
To have the gnome-terminal not close when exiting vim, try this:
  +
<syntaxhighlight lang="Bash">
  +
#!/bin/sh
  +
ARGS="$@"
  +
gnome-terminal -x sh -c "vim $ARGS; $SHELL"
  +
</syntaxhighlight>
  +
  +
Now you should get a normal gnome-terminal when exiting vim with the :q command.
  +
  +
--[[User:VimRulz|VimRulz]] 23:54, June 27, 2011 (UTC)

Latest revision as of 06:44, 13 July 2012

Tip 1655 Printable Monobook Previous Next

created June 14, 2010 · complexity basic · author A generic person · version 7.0


This tip shows how to use Vim from within a pop-up gnome terminal as an alternative to using gvim. Because most graphical terminals accept a "command string" that is executed when they start running, the technique shown here is easily generalized to other terminal types.

vim-gnome[]

Many applications can be configured with an external pop-up editor, but require "popping up" to be the editor's default mode (for example, File Roller, the GNOME desktop archive editor). This is a problem when you do not have gvim installed, or when you simply prefer to use "normal" Vim from within your preferred terminal (for example, gnome-terminal).

Create a file named vim-gnome with the following contents, and place it on your execution PATH (and use chmod +x vim-gnome to make vim-gnome executable):

#!/bin/sh
ARGS="$@"
gnome-terminal -e "vim $ARGS"

This wrapper handles passing extra arguments to Vim, so you can enter things like vim-gnome myfile.txt +42 to edit myfile.txt and jump to line 42.

Now you can use vim-gnome everywhere that you could have used gvim, or any other pop-up editor.

See also[]

Comments[]

To have the gnome-terminal not close when exiting vim, try this:

#!/bin/sh
ARGS="$@"
gnome-terminal -x sh -c "vim $ARGS; $SHELL"

Now you should get a normal gnome-terminal when exiting vim with the :q command.

--VimRulz 23:54, June 27, 2011 (UTC)