Quantcast

Developing a simple vim script:Program-test-tune-loop?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Developing a simple vim script:Program-test-tune-loop?

meino.cramer
Hi,

I want a simple vim script to go into my .vimrc.
Nothing fancy...only a piece of code to parse and
extract parts of a system file.

But a recognized that for doing this efficiently
that I dont know a important thing: The workflow!

When developing the script in my .vimrc directly
I had to restart vim every time I changed the script
and will get nasty message if I had screwed up the
script.

The question: What is the recommended workflow to
develop a script (no plugin!) - how to do the
iteration of "program - test - correct" most
efficiently?

Thanks a lot for any help in advance !

Cheers
Meino



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Developing a simple vim script:Program-test-tune-loop?

jrfranklin
A few tips to get you started...

(0) Read `:h usr_41.txt`.

(1) Vimscript autocompletion is available (see `:h i_CTRL-X_CTRL-V`).

(2) See `:h :@`.  This command will allow you to copy a region of Vimscript into a register and then run the contents of that register (useful for quickly testing a small snippet).

(3) Put autocommands in a block like this:

augroup [GROUP NAME HERE]
  autocmd!
  [YOUR AUTOCOMMANDS HERE...]
augroup END

This will allow you to source the same script (with ":so %") after writing it.  All of the commands will be deleted and then created again fresh.

(4) Declare functions with :function! instead of :function.  This will force the re-definition of the function whenever the script is sourced again.

Happy Vimming!
Jason

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Developing a simple vim script:Program-test-tune-loop?

jrfranklin
In reply to this post by meino.cramer
(5) One good mapping is...

nmap <silent> <Leader>s :update! | so %<CR>

This will write the file if it has changed and source it immediately so you can see the effect of your Vimscript.

There are many more optimizations.  Discovering them is part of the fun of Vim!

Best,
Jason

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Developing a simple vim script:Program-test-tune-loop?

meino.cramer
[hidden email] <[hidden email]> [17-02-20 17:09]:

> (5) One good mapping is...
>
> nmap <silent> <Leader>s :update! | so %<CR>
>
> This will write the file if it has changed and source it immediately so you can see the effect of your Vimscript.
>
> There are many more optimizations.  Discovering them is part of the fun of Vim!
>
> Best,
> Jason
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.


Hi Jason,

thanks *A LOT* for your two postings!
That will help me in many ways!!!

GREAT!

Cheers
Meino




--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Developing a simple vim script:Program-test-tune-loop?

jrfranklin
> Hi Jason,
>
> thanks *A LOT* for your two postings!
> That will help me in many ways!!!
>
> GREAT!
>
> Cheers
> Meino

Hey Meino,

One last tip I didn't think of earlier provides rapid access to the help system while editing Vimscript.  Use this autocommand in your vimrc:

augroup QuickHelp
  autocmd!
  autocmd FileType vim setlocal keywordprg=:help
augroup END

Putting this in your vimrc has an useful effect.  Placing your cursor on a Vimscript keyword (e.g. "autocmd") and pressing "K" in normal mode will open a help window for that keyword.  Try it out and see if it's useful.

Of course, you'll have to read the documentation to find out WHY this works!

Best wishes,
Jason

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...