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
0 votes
0 answers
23 views

calling vim with mpiexec says "Warning: Output is not to a terminal / Warning: Input is not from a terminal"

My question is a bit technical. For specific reason, I need to call vim after mpiexec. Example : mpiexec -n 1 vim mytext.txt But this gives the following warning message: Vim: Warning: Output is not ...
4 votes
1 answer
44 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 ...
  • 141
0 votes
2 answers
106 views

project-based config: how to load plugins/colors from custom subdir of $PWD when doing `vim -u local/vimrc ...`?

The Need, the Goal... By "project-based config" I mean a project contained in a git repo that contains all the vim configuration -- vimrc and plugins and colorschemes -- right there in the ...
  • 735
1 vote
2 answers
52 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"...
  • 735
0 votes
0 answers
38 views

Ex - silent mode won't read commands from a file when stdin is redirected

I'm starting vim in Ex mode, silent mode, on Windows 10, in a standard command prompt window. I'm trying to re-direct stdin from a file. I'm using the terminal version of vim 8.2.2824. It doesn't ...
0 votes
0 answers
34 views

Check if any vi process is editing a file, or swapfile exists?

I'm writing a script to ensure that everything I work on on my system is committed, pushed to Git etc. I'd also like to check if there are any vim swapfiles active (either in a running Vim, or from ...
  • 335
5 votes
1 answer
182 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 ...
  • 183
1 vote
1 answer
437 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, ...
  • 335
1 vote
2 answers
106 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 ...
0 votes
1 answer
161 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 ...
  • 3,203
2 votes
1 answer
207 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?
0 votes
2 answers
61 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: ...
  • 111
0 votes
1 answer
65 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 ...
  • 495
4 votes
3 answers
2k 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 ...
  • 527
6 votes
1 answer
138 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....
1 vote
1 answer
56 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 ...
  • 11
0 votes
1 answer
219 views

bash script to open file and translate text

I have followed your post and used :%s/\\u\(\x\{4\}\)/\=nr2char('0x'.submatch(1),1)/g to translate unicode escape sequences. However I have to open the file and need to press escape and paste your ...
3 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 ...
1 vote
0 answers
57 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 ...
3 votes
1 answer
585 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 ...
1 vote
2 answers
605 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 ...
  • 163
5 votes
1 answer
2k 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 ...
  • 769
4 votes
2 answers
683 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 ...
  • 5,988
3 votes
1 answer
306 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 [...
6 votes
1 answer
1k 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 (...
  • 63
3 votes
2 answers
18k 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 ...
3 votes
1 answer
159 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 |...
11 votes
1 answer
339 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 ...
  • 745
23 votes
5 answers
15k 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) ...
9 votes
2 answers
3k 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 ...
  • 659
8 votes
3 answers
247 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, ...
6 votes
1 answer
4k 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 ...
  • 6,556
1 vote
1 answer
58 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 ...
  • 560
2 votes
2 answers
417 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.
  • 205
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 ...
7 votes
3 answers
952 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 ...
1 vote
1 answer
288 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 ...
  • 1,331
5 votes
1 answer
192 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 ...
  • 151
14 votes
3 answers
14k 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 ...
  • 347
38 votes
1 answer
12k views

Setting a vim option from the command line?

How does one set a vim option when launching from bash or another shell?
  • 3,203
2 votes
2 answers
144 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 ...
  • 23
8 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?
7 votes
1 answer
122 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. ...
  • 2,399
-3 votes
1 answer
594 views

How to associate gvim with extensionless files on Windows? [closed]

I would like to set gvim as the default program for opening files which do not have an extension (e.g. no .txt, .php, .js, .css, .html etc...) suffix as part of the file name. e.g.: README or INSTALL. ...
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 ...
  • 748
3 votes
2 answers
836 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
  • 925
9 votes
3 answers
4k 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 ...
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 ...
  • 17.2k
27 votes
1 answer
13k 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 ...
  • 17.2k
26 votes
4 answers
9k 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/...
  • 17.2k