Linux allows you to enter multiple commands at one time. The only requirement is that you separate the commands with a semicolon. Running the combination of commands creates the directory and moves the file in one line.
Click Start, type cmd, and press Enter to open a command prompt window. In the Windows taskbar, right-click the command prompt window icon and select Command Prompt. A second command prompt window is opened.
A bar |
will allow you to do this. From :help :bar
'|'
can be used to separate commands, so you can give multiple commands in one line. If you want to use'|'
in an argument, precede it with'\'
.
Example:
:echo "hello" | echo "goodbye"
Output:
hello
goodbye
NB: You may find that your ~/.vimrc
doesn't support mapping |
, or \|
. In these cases, try using <bar>
instead.
Put <CR>
(Carriage Return/Enter) between and after commands. For example:
map <F5> :w<CR>:!make && ./run<CR>
Don't use |
because:
Some commands have problems if you use |
after them
|
does not work consistently in configuration files, see :help map_bar
You could define a function that executes your commands.
function Func()
:command
:command2
endfunction
And place this in, for example, your vimrc. Run the function with
exec Func()
The command seperator in vim is |
.
I've always used ^J
to separate multiple commands by pressing Ctrl+v, Ctrl+j.
Thought this might help someone trying to do substitutions in a chain and one fails
from a comment
%s/word/newword/ge | %s/word2/newword2/ge
You can use the e
flag to ignore the error when the string is not found.
You can create a new file, and write your commands on it. Then :so %
, which means source current file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With