vim: how to record norm commands?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I edit and correct a lot of identical files



using those commands



:%norm f^ID
:%s/s+$//
:%norm A,
:%norm GG$x


I also used the macro mode



qa


for record macro a



and



@a


to execute



But for some strange reason
or probably my error
it applied only some commands



My question is: is possible to save
those command in a script
and use



 vim -N -u NONE -n -c "set nomore" -S script.vi file.txt


Of course the syntax



:%norm f^ID
:%s/s+$//
:%norm A,
:%norm GG$x


Used in a script give me a error



Vim is 7.4 on slackware 14.2










share|improve this question























  • try -s ... and add a :x in the end. There is several options for sourcing files: -S ex-commands (no ":") or -s vim-commands
    – JJoao
    Sep 26 '17 at 12:14















up vote
1
down vote

favorite












I edit and correct a lot of identical files



using those commands



:%norm f^ID
:%s/s+$//
:%norm A,
:%norm GG$x


I also used the macro mode



qa


for record macro a



and



@a


to execute



But for some strange reason
or probably my error
it applied only some commands



My question is: is possible to save
those command in a script
and use



 vim -N -u NONE -n -c "set nomore" -S script.vi file.txt


Of course the syntax



:%norm f^ID
:%s/s+$//
:%norm A,
:%norm GG$x


Used in a script give me a error



Vim is 7.4 on slackware 14.2










share|improve this question























  • try -s ... and add a :x in the end. There is several options for sourcing files: -S ex-commands (no ":") or -s vim-commands
    – JJoao
    Sep 26 '17 at 12:14













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I edit and correct a lot of identical files



using those commands



:%norm f^ID
:%s/s+$//
:%norm A,
:%norm GG$x


I also used the macro mode



qa


for record macro a



and



@a


to execute



But for some strange reason
or probably my error
it applied only some commands



My question is: is possible to save
those command in a script
and use



 vim -N -u NONE -n -c "set nomore" -S script.vi file.txt


Of course the syntax



:%norm f^ID
:%s/s+$//
:%norm A,
:%norm GG$x


Used in a script give me a error



Vim is 7.4 on slackware 14.2










share|improve this question















I edit and correct a lot of identical files



using those commands



:%norm f^ID
:%s/s+$//
:%norm A,
:%norm GG$x


I also used the macro mode



qa


for record macro a



and



@a


to execute



But for some strange reason
or probably my error
it applied only some commands



My question is: is possible to save
those command in a script
and use



 vim -N -u NONE -n -c "set nomore" -S script.vi file.txt


Of course the syntax



:%norm f^ID
:%s/s+$//
:%norm A,
:%norm GG$x


Used in a script give me a error



Vim is 7.4 on slackware 14.2







vim macro






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 27 '17 at 19:51

























asked Sep 26 '17 at 11:50









elbarna

3,83693577




3,83693577











  • try -s ... and add a :x in the end. There is several options for sourcing files: -S ex-commands (no ":") or -s vim-commands
    – JJoao
    Sep 26 '17 at 12:14

















  • try -s ... and add a :x in the end. There is several options for sourcing files: -S ex-commands (no ":") or -s vim-commands
    – JJoao
    Sep 26 '17 at 12:14
















try -s ... and add a :x in the end. There is several options for sourcing files: -S ex-commands (no ":") or -s vim-commands
– JJoao
Sep 26 '17 at 12:14





try -s ... and add a :x in the end. There is several options for sourcing files: -S ex-commands (no ":") or -s vim-commands
– JJoao
Sep 26 '17 at 12:14











1 Answer
1






active

oldest

votes

















up vote
1
down vote













This is not exactly what you asked, but you can create vim scripts with your content. Lets start with a simple case:



$ cat noendspaces
#!/usr/bin/vim -s
:%s/ *$//
:r ! echo "#last changed by $USER in :" `date`
:x


and then...



$ chmod 755 noendspaces
$ for a in file*.txt
do
./noendspaces $a
done





share|improve this answer






















  • The syntax is ok,but doesn't work with norm commands,with other commands works but doesn't solve my problem
    – elbarna
    Sep 26 '17 at 15:35











  • @elbarna, I added a :%norm A, to my script and it worked. Could you detail the "doesn't work with norm commands"
    – JJoao
    Sep 26 '17 at 18:10










  • I have tried the script with my file and it doesn't work,use the same commands one by one on vim work
    – elbarna
    Sep 27 '17 at 10:33










  • @elbarna, strange! 1) could you please check which vim? 2) please make a small test with: line1=#!/usr/bin/vim -s, line 2=:%norm A, and line 3=:x and check if it adds ","
    – JJoao
    Sep 27 '17 at 10:54










  • vim 7.4 on Slackware 14.2
    – elbarna
    Sep 27 '17 at 19:51










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394517%2fvim-how-to-record-norm-commands%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













This is not exactly what you asked, but you can create vim scripts with your content. Lets start with a simple case:



$ cat noendspaces
#!/usr/bin/vim -s
:%s/ *$//
:r ! echo "#last changed by $USER in :" `date`
:x


and then...



$ chmod 755 noendspaces
$ for a in file*.txt
do
./noendspaces $a
done





share|improve this answer






















  • The syntax is ok,but doesn't work with norm commands,with other commands works but doesn't solve my problem
    – elbarna
    Sep 26 '17 at 15:35











  • @elbarna, I added a :%norm A, to my script and it worked. Could you detail the "doesn't work with norm commands"
    – JJoao
    Sep 26 '17 at 18:10










  • I have tried the script with my file and it doesn't work,use the same commands one by one on vim work
    – elbarna
    Sep 27 '17 at 10:33










  • @elbarna, strange! 1) could you please check which vim? 2) please make a small test with: line1=#!/usr/bin/vim -s, line 2=:%norm A, and line 3=:x and check if it adds ","
    – JJoao
    Sep 27 '17 at 10:54










  • vim 7.4 on Slackware 14.2
    – elbarna
    Sep 27 '17 at 19:51














up vote
1
down vote













This is not exactly what you asked, but you can create vim scripts with your content. Lets start with a simple case:



$ cat noendspaces
#!/usr/bin/vim -s
:%s/ *$//
:r ! echo "#last changed by $USER in :" `date`
:x


and then...



$ chmod 755 noendspaces
$ for a in file*.txt
do
./noendspaces $a
done





share|improve this answer






















  • The syntax is ok,but doesn't work with norm commands,with other commands works but doesn't solve my problem
    – elbarna
    Sep 26 '17 at 15:35











  • @elbarna, I added a :%norm A, to my script and it worked. Could you detail the "doesn't work with norm commands"
    – JJoao
    Sep 26 '17 at 18:10










  • I have tried the script with my file and it doesn't work,use the same commands one by one on vim work
    – elbarna
    Sep 27 '17 at 10:33










  • @elbarna, strange! 1) could you please check which vim? 2) please make a small test with: line1=#!/usr/bin/vim -s, line 2=:%norm A, and line 3=:x and check if it adds ","
    – JJoao
    Sep 27 '17 at 10:54










  • vim 7.4 on Slackware 14.2
    – elbarna
    Sep 27 '17 at 19:51












up vote
1
down vote










up vote
1
down vote









This is not exactly what you asked, but you can create vim scripts with your content. Lets start with a simple case:



$ cat noendspaces
#!/usr/bin/vim -s
:%s/ *$//
:r ! echo "#last changed by $USER in :" `date`
:x


and then...



$ chmod 755 noendspaces
$ for a in file*.txt
do
./noendspaces $a
done





share|improve this answer














This is not exactly what you asked, but you can create vim scripts with your content. Lets start with a simple case:



$ cat noendspaces
#!/usr/bin/vim -s
:%s/ *$//
:r ! echo "#last changed by $USER in :" `date`
:x


and then...



$ chmod 755 noendspaces
$ for a in file*.txt
do
./noendspaces $a
done






share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 26 '17 at 18:13

























answered Sep 26 '17 at 12:05









JJoao

6,7211826




6,7211826











  • The syntax is ok,but doesn't work with norm commands,with other commands works but doesn't solve my problem
    – elbarna
    Sep 26 '17 at 15:35











  • @elbarna, I added a :%norm A, to my script and it worked. Could you detail the "doesn't work with norm commands"
    – JJoao
    Sep 26 '17 at 18:10










  • I have tried the script with my file and it doesn't work,use the same commands one by one on vim work
    – elbarna
    Sep 27 '17 at 10:33










  • @elbarna, strange! 1) could you please check which vim? 2) please make a small test with: line1=#!/usr/bin/vim -s, line 2=:%norm A, and line 3=:x and check if it adds ","
    – JJoao
    Sep 27 '17 at 10:54










  • vim 7.4 on Slackware 14.2
    – elbarna
    Sep 27 '17 at 19:51
















  • The syntax is ok,but doesn't work with norm commands,with other commands works but doesn't solve my problem
    – elbarna
    Sep 26 '17 at 15:35











  • @elbarna, I added a :%norm A, to my script and it worked. Could you detail the "doesn't work with norm commands"
    – JJoao
    Sep 26 '17 at 18:10










  • I have tried the script with my file and it doesn't work,use the same commands one by one on vim work
    – elbarna
    Sep 27 '17 at 10:33










  • @elbarna, strange! 1) could you please check which vim? 2) please make a small test with: line1=#!/usr/bin/vim -s, line 2=:%norm A, and line 3=:x and check if it adds ","
    – JJoao
    Sep 27 '17 at 10:54










  • vim 7.4 on Slackware 14.2
    – elbarna
    Sep 27 '17 at 19:51















The syntax is ok,but doesn't work with norm commands,with other commands works but doesn't solve my problem
– elbarna
Sep 26 '17 at 15:35





The syntax is ok,but doesn't work with norm commands,with other commands works but doesn't solve my problem
– elbarna
Sep 26 '17 at 15:35













@elbarna, I added a :%norm A, to my script and it worked. Could you detail the "doesn't work with norm commands"
– JJoao
Sep 26 '17 at 18:10




@elbarna, I added a :%norm A, to my script and it worked. Could you detail the "doesn't work with norm commands"
– JJoao
Sep 26 '17 at 18:10












I have tried the script with my file and it doesn't work,use the same commands one by one on vim work
– elbarna
Sep 27 '17 at 10:33




I have tried the script with my file and it doesn't work,use the same commands one by one on vim work
– elbarna
Sep 27 '17 at 10:33












@elbarna, strange! 1) could you please check which vim? 2) please make a small test with: line1=#!/usr/bin/vim -s, line 2=:%norm A, and line 3=:x and check if it adds ","
– JJoao
Sep 27 '17 at 10:54




@elbarna, strange! 1) could you please check which vim? 2) please make a small test with: line1=#!/usr/bin/vim -s, line 2=:%norm A, and line 3=:x and check if it adds ","
– JJoao
Sep 27 '17 at 10:54












vim 7.4 on Slackware 14.2
– elbarna
Sep 27 '17 at 19:51




vim 7.4 on Slackware 14.2
– elbarna
Sep 27 '17 at 19:51

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394517%2fvim-how-to-record-norm-commands%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay