0

You can execute commands from vim like this:

:!cp <src> <dest>

However, the command is executed externally. The above can save typing and effort, but which are the commands that don't require the "!". Here are the only two I have found:

:cd <dest>
:pwd
Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37
  • 2
    Neither of those commands are native: neither executes the actual linux binaries. :cd for example will not change the working directory of the underlying terminal session. It will simply change the working directory of the current Vim session. – 3N4N Dec 05 '22 at 08:00
  • and what is "the current Vim session"? –  Dec 05 '22 at 21:02

1 Answers1

1

Vim may have a number of Ex commands that sound more or less the same as commands available in your shell but that doesn't necessarily make them "internal alternatives" or whatever you are after. They might work differently, they take different arguments or no arguments at all, they are not executed in your shell so they don't have access to shell-specific constructs like $_, etc.

If we take :cd <dest> and its shell counterpart :!cd <dest> as an example…

  • the former changes Vim's working directory while the latter doesn't,
  • the former changes the working directory for further :! commands but the latter doesn't,
  • etc.

Another example would be :sort vs :!sort. At a glance, they seem functionally equivalent (they sort lines), but the way they work and the options they provide are actually very different.

:grep, too, is different from :!grep, :ls is different from :!ls, etc.

Note also that there is no piping in Vim's command-line, which limits considerably how Ex commands compare to shell commands. Thinking about shortening :!ls | grep foo | sort -r to :ls | grep foo | sort r? Well, think again.

In other words, that "linux commands native to vim" concept makes no sense.

romainl
  • 40,486
  • 5
  • 85
  • 117
  • Also, if you were only able to find :cd and :pwd, then it means that you probably don't know "linux" well enough for any of this to make a difference. Don't waste your time, :help user-manual is waiting for you. – romainl Dec 05 '22 at 11:36
  • Okay, well not understanding it's reasonable i retroactively "didn't make any sense", but i suppose what your answer leaves out what exactly the differences are between the two types of vim commands. –  Dec 05 '22 at 21:02
  • There is only one type of Vim command, here. – romainl Dec 05 '22 at 21:25