How can I execute a bunch of editor commands stored in a file in VIM?

I read other posts, for example vim: Executing a list of editor commands and others. The answer is incomprehensible to me for my case. I have some editor commands that I created from an SQL query. It uses: s / foo / bar to change country codes (from FIPS to a custom set of codes). Here's a sample file:

:s/CB/CAMBO
:s/CQ/NMARI
:s/KV/KOSOV
:s/PP/PAPUA
...

I saved this in a file called fipsToNonStd.vim (not sure about the correct extension). I want to run these commands one by one. What is the easiest way to do this?

Thank! SO Rocks!

+3
source share
4 answers

, :source.

-, vim, :help :source.

+7

, .vim . , convert.vim:

:%s/CD/CAMBO/g
:%s/CQ/NMARI/g
" etcetera

Vim :

:so convert.vim

, , , vim? . , - . convert.vim :

:%s/CD/CAMBO/g
:%s/CQ/NMARI/g
" etcetera
:w!
:q

. , " ", , data.txt. :

vim -s convert.vim data.txt

/ .

+3

: source fileName

+1
source

You can put these lines in a function that will be called later: call FName

0
source

Source: https://habr.com/ru/post/1736161/


All Articles