Questions tagged [invocation]

Questions about the different options that vim can take from the shell and the different commands to start the editor.

Filter by
Sorted by
Tagged with
44 votes
1 answer
14k views

Setting a vim option from the command line?

How does one set a vim option when launching from bash or another shell?
leeand00's user avatar
  • 3,491
41 votes
5 answers
5k views

Terminal borked after invoking Vim with xargs

I've sometimes tried invoking Vim using xargs, like this: find . -name '*.java' | xargs vim … which kind of works: As Vim launches, I see the following warning flash briefly: Vim: Warning: Input ...
200_success's user avatar
  • 9,489
29 votes
1 answer
14k views

How to edit files non-interactively (e.g. in pipeline)?

I would like to edit files passed in pipeline input using vim in non-interactive way or edit files in-place (similar to sed). Few examples using sed: $ sed -i'.bak' s/foo/test/g file # Edit file ...
kenorb's user avatar
  • 18.3k
29 votes
3 answers
6k views

Can I open a file in an existing Vim instance from an external command?

Some applications have the notion of a "session", where you can run a command to load a file in an existing instance of an application. For example, when I type: $ firefox http://vi.stackexchange....
ideasman42's user avatar
  • 3,723
27 votes
4 answers
11k views

How to edit content from the standard input?

I would like to edit content in vim which was dynamically generated from the command-line without having the file yet. In example: $ echo This is example. | vim /dev/stdin $ cat /etc/hosts | vim /dev/...
kenorb's user avatar
  • 18.3k
26 votes
3 answers
9k views

Automatically load Vi into insert mode

I use Vi as my preferred (and, in fact, only) text editor on Linux Systems. I know how to change modes from normal to insert, and vice-versa. Is it possible to have Vi automatically load into Insert ...
user avatar
24 votes
5 answers
17k views

Is it possible to pipe vim commands to vim?

I want to run the following shell. wea-this is the end of the second word | vim j exit 0 Which I had hoped would pipe the key strokes w (move forward a word) then e (end of the word) then a (append) ...
Jason Basanese's user avatar
14 votes
3 answers
15k views

How do I tell if Vi or Vim is installed on my Linux distribution?

I use Kubuntu 14.04 with its default installation (bash, Konsole). I want to learn a powerful, all-keyboard, text editor, and settled on one of these: Vi, Vim, Emacs, (and I'll learn Nano since it's ...
user12711's user avatar
  • 367
11 votes
1 answer
353 views

Experimenting with vim/gvim in "virgin" mode

Sometimes, I would like to try a trick I find in the internet. It is often helpful to try this in vim (gvim if it is a gui trick), in virgin mode, i.e., without loading all my ~/.vimrc stuff. Do you ...
Yossi Gil's user avatar
  • 755
10 votes
4 answers
1k views

Can :Explore be started from the terminal?

When using Vim you can use :Explore to browser through files and folders. Is there a simple way to start Vim in "Explore mode" from the terminal? Can I do this by just giving Vim some argument?
Gonçalo Ribeiro's user avatar
10 votes
3 answers
5k views

How can I start vim and then execute a particular command that includes a \, from the command line?

In my ~/.vimrc, I have a command defined approximately like this: nnoremap <expr> <Leader>n ':new ~/Notes/' . strftime('%F') . '-' It is designed for creating notes files that contain ...
Andrew Ferrier's user avatar
10 votes
2 answers
4k views

How to write whole buffer to standard output from the command line?

I would like to write whole buffer into standard output (/dev/stdout) instead of the file and the following command works as expected while editing the file: :w >> /dev/stdout Hint: Press ...
kenorb's user avatar
  • 18.3k
9 votes
2 answers
4k views

Why won't vim source my .vimrc file

Today, I found my .vimrc didn't take effect. It was ok just hours ago. When I launched vim with $vim --plugin, :scriptnames echoed nothing: .vimrc file was not sourced. (Note: /etc/vimrc was removed ...
Feng Yu's user avatar
  • 659
8 votes
3 answers
267 views

How do I introduce a "light mode", in which not all plugins are loaded?

My Vim config includes plugins that try to handle current project, build tags, etc. This is quite useful for my daily programming in Vim, but it's just annoying when I use Vim for some quick edits, ...
Dmitry Frank's user avatar
7 votes
7 answers
2k views

Is there a vim command line option to edit last edited file?

Is there a way to run vim from command line to edit the last edited file? Let say I first edit file giorgio.sh: $ vi giorgio.sh Afterwards, I exit back to terminal $ do something... $ do something ...
Giorgio Robino's user avatar
7 votes
3 answers
1k views

How to specify the content of a new buffer from command line?

Is there a way to call Vim in such a way that it opens a buffer with some content specified on the terminal, i.e. not saved in a file? For example, I would like to run vim and have it open a buffer ...
Gonçalo Ribeiro's user avatar
7 votes
1 answer
128 views

How to search the help docs from a command prompt?

I find my self often, especially after this site was created, opening Vim just to type :h ... or :helpgrep .... What I would like to do is to run Vim and immediately open the help topic that I want. ...
elyashiv's user avatar
  • 2,429
6 votes
3 answers
1k views

Switching to the local directory after loading a file?

When running gvim by double clicking with a file in a graphical file manager, like nautilus, the vim instance is called with a strange current directory (seems root sometime, but I am not sure). This ...
Rmano's user avatar
  • 758
6 votes
1 answer
193 views

How can I make sure all buffers end up as tab or force remaining buffers into tabs?

I am using Vim 7.3 for no particularly compelling reason on an old system I am forced to work on. It's an internal system and it will eventually be replaced by a more modern version of the same distro....
0xC0000022L's user avatar
6 votes
3 answers
3k views

How can I read a command-line argument in vimrc?

Here is a situation: I want to manage my working environment on multiple projects separately, and all of them should have its own session (Session.vim) to save and restore. So I would like to launch ...
Blaszard's user avatar
  • 555
6 votes
1 answer
2k views

How to use a specific vimrc file and still load the usual files?

I'd like to automatically set my Vim preferences on the root account, when I use it (throught a sudo bash or sudo su-like command), without changing the default configuration of the root account (...
Kzwix's user avatar
  • 63
6 votes
1 answer
5k views

How to redirect the output of a command as the quickfix list to a vim server / function?

When I click on a link in thunderbird and firefox is already running, it doesn't open a new window, just a new tab. I want the same thing for vim: no matter where I am and how I send a bunch of files ...
saginaw's user avatar
  • 6,736
5 votes
2 answers
725 views

How to detect whether Vim has been invoked by another shell command?

I would like to modify the behavior of one of my mapping but only when Vim is reading data which were piped to it by $ vipe. The mapping closes/quits the current window/session depending on certain ...
user9433424's user avatar
  • 6,118
5 votes
1 answer
3k views

Using the ex mode command line (-c), how would I insert text?

I am interested in mastering the art of using ex from the command line (vi -esc <commands> / ex -sc <commands>). I got the basics worked out, but one thing eludes me: How do I add text ...
DevSolar's user avatar
  • 789
5 votes
1 answer
198 views

Cannot open an url (empty buffer)

I have some strange troubles with opening an url in vim. Judging from this answer, this should be pretty easy, but when I'm doing this: $ vim http://www.ietf.org/rfc/rfc7386.txt I getting a message ...
erthalion's user avatar
  • 151
5 votes
1 answer
255 views

Start vim with ex-command and append it to vim's command history

When I start vim with an ex-command as command line parameter, it won't show up in vim's command history. Why? Can I tell vim to do so? Minimal example: vim -c 'execute "help -c"' Why I'm ...
MaxGyver's user avatar
  • 229
4 votes
1 answer
2k views

Call vim command from shell, and suppress output while it operates

I'm setting up a vim environment install script. I'm using vim-plug for plugin management. What I'd like to do is, from the install.sh, run vim and call PlugInstall to trigger plugin download and ...
silico-biomancer's user avatar
4 votes
1 answer
54 views

Speedier indentation of many files

I recently needed to re-indent a large number of files. I used variations of: find . -type f -exec vim -c "normal gg=GZZ" {} \; Which worked well, but incredibly slowly (across several ...
Allen's user avatar
  • 141
4 votes
0 answers
52 views

vim ~/symlink-to-dir/file resolves symlink to target instead of symlink path

vim ~/symlink-to-dir/file resolves the symlink and shows me ~/real-dir/file in the status line and in echo expand('%'). After a few hours of experiments I found the problem is reproducible. The ...
phd's user avatar
  • 141
3 votes
2 answers
19k views

Vim not sourcing files on startup

I am root on the machine, and have my .vimrc at /root/.vimrc. Vim ignores this, even though # echo $HOME /root If I do # vim -u /root/.vimrc some-file-to-edit vim still ignores it. Setting ...
Edward Newell's user avatar
3 votes
2 answers
920 views

How can I automatically execute normal mode keystrokes with a terminal command when opening Vim?

How do I run vim with file.txt and screen center at line 100? Basically I would like to use zz mapping when starting Vim. This does not work: vim -c "zz" file.txt +100
name's user avatar
  • 965
3 votes
1 answer
311 views

How to comment a line directly from bash using vim?

What I usually do from bash/vim ... is open file with vim go to line to comment comment a line save and quit My file is /usr/local/etc/php/7.0/conf.d/ext-xdebug.ini and the initial content is [...
sensorario's user avatar
3 votes
1 answer
630 views

Read from standard input and close if empty

I'm not sure it's even possible, but I'd like to force vim to quit if reading from stdin gave empty data (0 bytes). The reason is when I'm running commands that may output something containing ...
Alexander Solovets's user avatar
3 votes
1 answer
163 views

How can I select a syntax highlighting at the (shell-) command line?

Usually, vim will get the highlighting right from the file extension, but this obviously doesn't work when I'm displaying content read from standard input. cat File.hs | some | processing | pipeline |...
leftaroundabout's user avatar
2 votes
2 answers
509 views

How do I open multiple files from find each in a separate tab in vim?

I would like to find multiple files and open them all in tabs within the same vim instance.
andorov's user avatar
  • 205
2 votes
1 answer
402 views

Open or create a specific Vimwiki page from a command prompt

For opening the index page of my Vimwiki instance, I have the following alias in my ~/.bashrc: alias vimwiki='vim -c VimwikiIndex' But how to open a specific Vimwiki page right from a command prompt?
Alexander Pozdneev's user avatar
2 votes
2 answers
150 views

How to add a string to cursor point of gvim through a shell script

When gvim is opened it saves the cursor position whether it is minimized or not. So I'm curious whether it is possible to add a string starting from the cursor blinking position by running a shell ...
ikisuru's user avatar
  • 23
1 vote
2 answers
112 views

Open file, make changes, save it as a new one. In one step, using the Windows command prompt

I have a file foo.txt with just a one line ab. I want to launch Vim in such a way that it will open this file, swap characters using xp, and then save it as bar.txt. Something like this: gvim foo.txt ...
john c. j.'s user avatar
1 vote
1 answer
79 views

How can I suppress feedback when calling vim with certain commands?

I'm trying to automatically delete useless headers when calling vim from mutt. I've tried running vim with the following command. vim +'0,/^$/g/^\(Cc\|Bcc\|Reply-To\): $/d' /tmp/test However, I get ...
Sparhawk's user avatar
  • 580
1 vote
1 answer
102 views

How do I open vim from the command-line at a particular tag?

I have set up ctags to generate a tags file for my code base. I can now jump to definitions of functions by running :tag FUNCTIONNAME or by pressing ctrl-] when my cursor is on the invocation of a ...
Flimm's user avatar
  • 2,202
1 vote
2 answers
69 views

how to load multiple files into separate buffers from zsh command line?

I have a list of files like step-1.py, step-2.py etc and if I try to open them with vim files-*.py then I get a list of buffers like: :ls 1 %a "step-10.py" 2 "step-11.py"...
alec's user avatar
  • 785
1 vote
1 answer
60 views

Launching Vim with a file as argument does not work, if my .vimrc contains a `:cd` command

UPDATE: after playing around with my vimrc file I discovered this this won't work cd c:\myUsualFolder set encoding=utf-8 but this will: set encoding=utf-8 cd c:\myUsualFolder If I launch Vim ...
noob's user avatar
  • 11
1 vote
1 answer
365 views

How to open multiple files except some files?

Suppose we have several files f11.txt f21.txt f31.txt f01.txt f02.txt f03.txt Is there any Vim option such that I can open all files except for f0*.txt? Something like gvim -O * --exclude=*0*? (-O ...
user3813057's user avatar
  • 1,451
1 vote
1 answer
398 views

Setting custom global variables from command-line with `nvim` command

Occasionally I would like to override my standard nvim configuration, for example, to tell it not to load vimtex's folding configuration for a very large or complicated tex file for which I don't need ...
Alex Roberts's user avatar
1 vote
1 answer
896 views

Load plugins in vim started with --noplugin

I have my $EDITOR set to vim --noplugin -n -i NONE +star, which is what I usually want when committing with git etc. However, sometimes I decide I need those plugins (the builtin ~/.vim/pack kind, ...
usretc's user avatar
  • 375
1 vote
1 answer
254 views

How to escape a single quote when passing an ex-mode command from the command line, back to the command line?

Here is the command I'm trying to escape a ' from bash, to vis' to ex-mode, and then back to bash so it can be read into the buffer again: vi -c 'sp | enew | read ! echo "Use to jump between ...
leeand00's user avatar
  • 3,491
1 vote
2 answers
776 views

How to combine reading from stdin (- invocation argument) with ++opt

I'm trying to combine two features of vim, but it doesn't seem to be possible. 1: vim - The first feature is invoking vim with a single-dash argument, which causes vim to read stdin and use the ...
bgoldst's user avatar
  • 163
1 vote
0 answers
63 views

indenting with ':g' command not working from the command line

When I need to work with some scrambled javascript/json code, one of my first steps is to introduce proper line breaks, followed by proper brace based indentation. For the later, I found the following ...
cmaster - reinstate monica's user avatar
0 votes
2 answers
84 views

Open some files in split and some other in tab at the vim invocation

I have four files file1, file2, file3, & file4. So I want to open them with vim directly from command line and get the following structure: Tabulation 1: file1 taking whole tab Tabulation 2: ...
fauve's user avatar
  • 111
0 votes
1 answer
67 views

Command line argument for lengthy command

I keep a sys.md file where I record a dated entry of every modification I make to my system (mostly installations of software, sometimes configuration changes) and based on an old Hacker News link ...
mas's user avatar
  • 555