Questions tagged [command-line]

Questions on ex- or colon-commands. For questions about command-line options used to launch the editor, use the [invocation] tag.

Filter by
Sorted by
Tagged with
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.1k
28 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.1k
15 votes
4 answers
31k views

How to split a line into multiple lines efficiently?

I've been receiving logged data in a text file that is just one long line with each value separated by a space. Is there a command or set of commands that will split one line into multiple lines?
Dom's user avatar
  • 3,265
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.1k
83 votes
1 answer
36k views

How to open multiple files in split mode?

I know how to split windows in vim, but it's possible to open multiple files using vim in split mode (at startup) from the command line? In example: vim file1 file2 file3 or: vim *.cpp
kenorb's user avatar
  • 18.1k
12 votes
2 answers
2k views

Zsh-like tab completion of partial paths

Related to Bash-like partial tab-complete for filenames in Vim One of the truly fantastic features of zsh is that you can type, for example, ls /u/s/m/m/who.1, press Tab and have it complete to ls /...
muru's user avatar
  • 24.7k
18 votes
1 answer
2k views

Bash-like partial tab-complete for filenames in Vim

In Bash, when there are several files with the same prefix and I type part of the prefix and hit Tab, it completes the common prefix and allows me to continue typing to differentiate among the ...
John O'M.'s user avatar
  • 8,462
4 votes
1 answer
103 views

Can the command-line window be entered without interrupting macro recording?

I'm having a problem using the command-line window (help cmdwin), which is extremely useful, but it doesn't play well with macros. cmdwin is invoked with q:, so if there is a macro being recorded, ...
mwcz's user avatar
  • 245
8 votes
1 answer
203 views

Running cleanup commands only for edited lines possible?

Referring to clean-up tasks like (but not limited to) the ones detailed in these questions: Re-indenting badly indented code What's the simplest way to strip trailing whitespace from all lines in ...
guido's user avatar
  • 1,747
27 votes
2 answers
5k views

How to save a file for which I have no write permissions?

Sometimes it happens that I open a file and make some modifications as my own user, without noticing or "forgetting" to noticing the [read-only] warning in the status line (ie. some random /etc config ...
guido's user avatar
  • 1,747
16 votes
1 answer
1k views

How is command history resolved between multiple instances of Vim?

Vim keeps a history of ex commands (accessible via :↑ and q:), and that history persists after quitting. If I run multiple instances of Vim (same user, same home directory), how does Vim arbitrate ...
200_success's user avatar
  • 9,359
20 votes
3 answers
447 views

What is the '[Command Line]' that sometimes comes up when I try to quit, and how can I quickly exit it?

Occasionally when I try to quit Vim, I get something that looks like this: I'm not sure how I accidentally invoke this, but my current method for escaping it is to hit random keys and eventually it ...
Undo's user avatar
  • 2,561
5 votes
2 answers
112 views

How can I go into a directory in filename completion?

Consider a directory structure like this: topdir/ file1 file2 foo/ bar1 bar2 Say I want to open some file in foo/ in a new tab. I would first write :tabe topdir/, and then keep hitting ...
wchargin's user avatar
  • 2,707

1
6 7 8 9
10