Monday, January 28, 2013

Augmenting Octave with Vim

Integrating the powerful mathematical package, Octave, with the flexible editor, Vim.

Today, I'm sharing some tips to use the vim editor inside the Octave interactive command line.

The octaverc file


The first thing towards customizing Octave is creating an .octaverc file, if you don't have one already. The .octaverc file holds some Octave commands that are executed every time you launch Octave.

We'll work with the .octaverc file that lives in your home directory, which is user specific.
# Create/modify .octaverc in your home folder
vim ~/.octaverc
A good starting .octaverc file looks as follows:

Using vim as editor in Octave


Next, let's set vim as the default editor in Octave. (source of information)
# Add extra configuration
vim ~/.octaverc
Open the .octaverc file and append the following:
Now you can call vim from within Octave, and use it in command line mode, i.e. without opening an (unnecessary) additional window.

As a bonus you get a function template.

Now, let's tweak vim for extra features!

Adding syntax highlighting


We'll add syntax coloring/highlighting to vim. Similar to the .octaverc file, vim also has a configuration file named .vimrc. Before touching the .vimrc file, you'll need to grab a vim syntax file from here (grab the latest version).

Next you'll need to drop that octave.vim file in the following directory: ~/.vim/syntax.
# If you don't have the folders already
mkdir -p ~/.vim/syntax
mv /path/to/downloaded/octave.vim ~/.vim/syntax/octave.vim
Next, you'll need to append the following lines in your .vimrc file.
Let's try editing a file inside Octave again.

Added Octave syntax highlighting for vim.

Execute Octave scripts from within vim


Here is where the magic comes in. With this hack, you'll be able to test the octave script you are editing in vim, inside vim and without leaving vim. In other words, you'll be able to use the F5 key to run your script, just like you do in the Matlab editor.

Without further ado, you'll need to add this to your .vimrc
Let's test the magic.



Executing an Octave script from within vim using the F5 key in normal mode.

I need to inform you that this hack adds two extra lines of code to your script:

"pkg load all" at the beginning of your code. Which grants access to all functions inside the extra Octave packages.

"pause" at the end of your code. Without this you won't be able to see the plots drawn in your script.

When the execution of the script finishes, these two lines are removed.

That's all folks, happy coding!

34 comments:

  1. Thanks! This works great.

    I found that vim in Apple's Terminal doesn't seem to work with the F5 thing, though: No biggie, MacVim does it right and nails it.


    ReplyDelete
    Replies
    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
    2. Selling USA FRESH SPAMMED SSN Leads/Fullz, along with Driving License/ID Number with EXCELLENT connectivity.

      **PRICE**
      >>1$ FOR EACH FULLZ WITHOUT DL NUMBER
      >>2$ FOR EACH LEAD/FULLZ/PROFILE
      >>5$ FOR EACH PREMIUM LEAD/FULLZ/PROFILE

      **DETAILS IN EACH LEAD/FULLZ**

      ->FULL NAME
      ->SSN
      ->DATE OF BIRTH
      ->DRIVING LICENSE NUMBER WITH EXPIRY DATE
      ->ADDRESS WITH ZIP
      ->PHONE NUMBER, EMAIL, I.P ADDRESS
      ->EMPLOYEE DETAILS
      ->REALTIONSHIP DETAILS
      ->MORTGAGE INFO
      ->BANK ACCOUNT DETAILS

      >All Leads are Tested & Verified.
      >Invalid info found, will be replaced.
      >Serious buyers will be welcome & I will give discounts on bulk orders.
      >Fresh spammed data of USA Credit Bureau
      >Good credit Scores, 700 minimum scores
      >Bulk order will be preferable
      >Minimum order 20 leads/fullz
      >Hope for the long term business
      >You can asked for samples, specific states & zips (if needed)
      >Payment mode BTC, ETH, LTC, Paypal & PERFECT MONEY

      Email > leads.sellers1212@gmail.com
      Telegram > @leadsupplier
      ICQ > 752822040

      ''OTHER GADGETS PROVIDING''

      >SSN Fullz
      >Dead Fullz
      >Carding Tutorials
      >Hacking Tutorials
      >SMTP Linux Root
      >DUMPS with pins track 1 and 2
      >Sock Tools
      >Server I.P's
      >USA emails with passwords (bulk order preferable)

      **Contact 24/7**

      Email > leads.sellers1212@gmail.com
      Telegram > @leadsupplier
      ICQ > 752822040

      Delete
  2. Should that be a " character instead of a # for the comment in .vimrc? I.e.:

    " F5 executes the octave script you are editing

    ReplyDelete
  3. I'm having some trouble with the path variable in Octave.

    I put the following in my octaverc file:
    edit editor 'vim > /dev/tty 2>&1 < /dev/tty %s'

    and I edited my system path to include the parent director of vim74.exe

    however, when I restart Octave and type:
    >> edit foo.m

    it reports the following error:
    The system cannot find the path specified

    Anyone have any suggestions?

    ReplyDelete
  4. I'm on windows, and there is no /dev/tty, so that was the problem. The following seems to work:

    edit editor "gvim %s"

    Is there an equivalent for /dev/tty on windows that I should use?

    ReplyDelete
  5. I've enhanced the executing function. With my version the cursor jumps back to the position, where it was before pressing f5:

    " F5 executes the octave script you are editing
    autocmd FileType octave map maggOpkg load allGopause:w:!octave -qf %ddggdd:w`a

    Happy Coding!

    ReplyDelete
  6. During to long search I have perfect blog. Your post is very reachable to all I love your blog. Why you not update about boom lift & Industrial Aluminium Scaffolding.

    ReplyDelete
  7. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definitely interested in this one. Just thought that I would post and let you know. Nice! thank you so much! Thank you for sharing.

    ReplyDelete
  8. Wow, amazing blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is fantastic, let alone the content!

    3D Animation services in Atlanta
    Cheap Rate Chatbot Development Service
    Cheap Rate Mobile app development in Coimbatore

    ReplyDelete
  9. Wow, Great information and this is very useful for us.

    Aluminium scaffolding hire

    ReplyDelete
  10. AE Clicks is one of the top website development company in dubai. With a team of highly skilled web developers and web designers, we have successfully completed over 300+ projects across various industries.

    ReplyDelete
  11. Thanks for provide great informatic and looking beautiful blog, really nice required information & the things i never imagined and i would request, wright more blog and blog post like that for us. Thanks you once agian
    we offer services birth certificate in delhi
    which inculde name add in birth certificate and
    birth certificate correction complete process is online and we offer
    birth certificate and we offer this birth certificate online same service offers at yourdoorstep at birth certificate in ghaziabad
    our dream to provide birth certificate in india and other staes like birth certificate in bengaluru and birth certificate in gurgaon book service with us birth certificate in noida also, service at yoursdoorstep only birth certificate in india or

    ReplyDelete
  12. Selling USA FRESH SPAMMED SSN Leads/Fullz, along with Driving License/ID Number with EXCELLENT connectivity.

    **PRICE**
    >>1$ FOR EACH FULLZ WITHOUT DL NUMBER
    >>2$ FOR EACH LEAD/FULLZ/PROFILE
    >>5$ FOR EACH PREMIUM LEAD/FULLZ/PROFILE

    **DETAILS IN EACH LEAD/FULLZ**

    ->FULL NAME
    ->SSN
    ->DATE OF BIRTH
    ->DRIVING LICENSE NUMBER WITH EXPIRY DATE
    ->ADDRESS WITH ZIP
    ->PHONE NUMBER, EMAIL, I.P ADDRESS
    ->EMPLOYEE DETAILS
    ->REALTIONSHIP DETAILS
    ->MORTGAGE INFO
    ->BANK ACCOUNT DETAILS

    >All Leads are Tested & Verified.
    >Invalid info found, will be replaced.
    >Serious buyers will be welcome & I will give discounts on bulk orders.
    >Fresh spammed data of USA Credit Bureau
    >Good credit Scores, 700 minimum scores
    >Bulk order will be preferable
    >Minimum order 20 leads/fullz
    >Hope for the long term business
    >You can asked for samples, specific states & zips (if needed)
    >Payment mode BTC, ETH, LTC, Paypal & PERFECT MONEY

    Email > leads.sellers1212@gmail.com
    Telegram > @leadsupplier
    ICQ > 752822040

    ''OTHER GADGETS PROVIDING''

    >SSN Fullz
    >Dead Fullz
    >Carding Tutorials
    >Hacking Tutorials
    >SMTP Linux Root
    >DUMPS with pins track 1 and 2
    >Sock Tools
    >Server I.P's
    >USA emails with passwords (bulk order preferable)

    **Contact 24/7**

    Email > leads.sellers1212@gmail.com
    Telegram > @leadsupplier
    ICQ > 752822040

    ReplyDelete
  13. I simply want to tell you that I am very new to blogging and site-building and really enjoyed your blog. Likely I’m likely to bookmark your website . You amazingly have superb writings. Cheers for sharing with us your web page. 야설

    Also feel free to visit may web page check this link 한국야동

    ReplyDelete
  14. repeat post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here. 야동

    Also feel free to visit may web page check this link 일본야동

    ReplyDelete
  15. This is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog. 야동

    Also feel free to visit may web page check this link 일본야동

    ReplyDelete
  16. This is a smart blog. I mean it. You have so much knowledge about this issue, and so much passion. You also know how to make people rally behind it, obviously from the responses. 국산야동

    Also feel free to visit may web page check this link 야설

    ReplyDelete
  17. Very good blog post about plastering a one bed flat. I am very happy to see this post and interested to find another good post in coming days. Thanks for it 한국야동

    Also feel free to visit may web page check this link 야설

    ReplyDelete