Editing How to open files in specific Vim instance

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 11: Line 11:
 
Say you have a mapping to open file in Vim which looks like this:
 
Say you have a mapping to open file in Vim which looks like this:
  
<syntaxhighlight lang="vim">
+
<source lang="vim">
 
nnoremap o :!gvim --remote-tab-silent %f &<cr>
 
nnoremap o :!gvim --remote-tab-silent %f &<cr>
</syntaxhighlight>
+
</source>
  
 
Same should be applicable to <code>'vicmd'</code>/<code>'vixcmd'</code> options.
 
Same should be applicable to <code>'vicmd'</code>/<code>'vixcmd'</code> options.
Line 25: Line 25:
 
Vim invocation command:
 
Vim invocation command:
  
<syntaxhighlight lang="vim">
+
<source lang="vim">
 
nnoremap o :!gvim $VIMARGS --remote-tab-silent %f &<cr>
 
nnoremap o :!gvim $VIMARGS --remote-tab-silent %f &<cr>
</syntaxhighlight>
+
</source>
  
 
Here <code>$VIMARGS</code> can include anything and we want to put
 
Here <code>$VIMARGS</code> can include anything and we want to put
Line 41: Line 41:
 
Setting environment variable looks like this:
 
Setting environment variable looks like this:
  
<syntaxhighlight lang="vim">
+
<source lang="vim">
 
let $VIMARGS='--servername work'
 
let $VIMARGS='--servername work'
</syntaxhighlight>
+
</source>
  
 
==== Command to pick target ====
 
==== Command to pick target ====
Line 51: Line 51:
 
better to add a command which would set target.  Here it is:
 
better to add a command which would set target.  Here it is:
  
<syntaxhighlight lang="vim">
+
<source lang="vim">
 
command! target :let $VIMARGS = '--servername "%a"'
 
command! target :let $VIMARGS = '--servername "%a"'
</syntaxhighlight>
+
</source>
  
 
That's it, now simply running <code>:target project1</code> will cause all files
 
That's it, now simply running <code>:target project1</code> will cause all files
Line 72: Line 72:
 
<code>~/.bashrc</code>), for example:
 
<code>~/.bashrc</code>), for example:
  
<syntaxhighlight lang="bash">
+
<source lang="bash">
 
function g()
 
function g()
 
{
 
{
 
     gvim $VIMARGS --remote-tab-silent "$@"
 
     gvim $VIMARGS --remote-tab-silent "$@"
 
}
 
}
</syntaxhighlight>
+
</source>
  
 
No need for double quotes around <code>$VIMARGS</code> because we don't
 
No need for double quotes around <code>$VIMARGS</code> because we don't
Line 91: Line 91:
 
following manner:
 
following manner:
  
<syntaxhighlight lang="vim">
+
<source lang="vim">
 
command! target : let $VIMARGS = '--servername "%a"'
 
command! target : let $VIMARGS = '--servername "%a"'
 
               \| execute "!tmux %%i set-environment VIMARGS '".$VIMARGS."'"
 
               \| execute "!tmux %%i set-environment VIMARGS '".$VIMARGS."'"
</syntaxhighlight>
+
</source>
  
 
Here we set <code>$VIMARGS</code> variable for all new panes/windows of
 
Here we set <code>$VIMARGS</code> variable for all new panes/windows of

Please note that all contributions to Vifm Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Vifm:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)