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
1answer
40 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 ...
1
vote
2answers
209 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 ...
5
votes
1answer
67 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
1answer
42 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 ...
0
votes
1answer
133 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 ...
2
votes
1answer
238 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
0answers
49 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
1answer
374 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 ...
0
votes
2answers
168 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 ...
1
vote
1answer
751 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 ...
4
votes
2answers
393 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 ...
3
votes
1answer
289 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
1answer
538 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 (...
3
votes
2answers
7k 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
1answer
112 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
1answer
287 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 ...
18
votes
5answers
6k 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
2answers
1k 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 ...
8
votes
3answers
179 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, ...
4
votes
1answer
2k 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 ...
1
vote
1answer
43 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 ...
2
votes
2answers
70 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.
5
votes
7answers
659 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
3answers
416 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 ...
0
votes
1answer
106 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 ...
5
votes
1answer
123 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 ...
14
votes
3answers
7k 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 ...
23
votes
1answer
6k views

Setting a vim option from the command line?

How does one set a vim option when launching from bash or another shell?
2
votes
2answers
136 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 ...
8
votes
4answers
267 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
1answer
106 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. ...
-3
votes
1answer
425 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; for instance the file ...
6
votes
3answers
759 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 ...
2
votes
2answers
450 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
8
votes
3answers
2k 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 ...
9
votes
2answers
2k 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 ...
23
votes
1answer
7k 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 ...
15
votes
4answers
3k 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 /...
29
votes
4answers
2k 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 ...
20
votes
2answers
2k 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....
21
votes
4answers
4k 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 verse. Is it possible to have Vi automatically load into Insert ...