DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 22nd September 2022
victorvas victorvas is offline
Real Name: Victor
Linux
 
Join Date: May 2019
Posts: 148
Question Vim9 Script - worth learning?

Vim 9.0, the new version of my favorite text editor has been released.
They replaced the old VimScript with new Vim9 Script, breaking compatibility with older versions of Vim and broke the compatibility with Vi text editor.
I have 2 options:
1. Learn the new Vim9 Script and rewrite my Vim config.
2. Learn Lua programming language, switch from Vim to NeoVim and rewrite my config in Lua.
Which one should I do?
Reply With Quote
  #2   (View Single Post)  
Old 22nd September 2022
roddierod's Avatar
roddierod roddierod is offline
Real Name: Rod Person
VPN Cryptographer
 
Join Date: Apr 2008
Location: Pittsburgh, Pa
Posts: 437
Default

I installed Vim9 on my windows installation and my old config works just fine except one plugin - YouCompleteMe - which seems not to be able to find Python.

From my brief reading of VimScript doc it looks to mostly target plugin creators.

This is in no way exhaustive, I installed Vim9...used my existing config.
Did :PluginInstall to get my vundle plugins installed.
Ran it and did stuff. Works.

YMMV.
__________________
"The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words." -Philip K. Dick
Reply With Quote
  #3   (View Single Post)  
Old 23rd September 2022
victorvas victorvas is offline
Real Name: Victor
Linux
 
Join Date: May 2019
Posts: 148
Default

roddierod, if my old config will work in Vim9, then I have nothing to worry about, thanks!
Prevet, ed scripts? Sounds interesting!
Reply With Quote
  #4   (View Single Post)  
Old 3rd October 2022
Carpetsmoker's Avatar
Carpetsmoker Carpetsmoker is offline
Real Name: Martin
Tcpdump Spy
 
Join Date: Apr 2008
Location: Netherlands
Posts: 2,243
Default

Quote:
Originally Posted by roddierod View Post
From my brief reading of VimScript doc it looks to mostly target plugin creators.
The biggest upshot of Vim9Script for your vimrc file is that multi-line commands and autocmds are much easier; for example:

Code:
# Go to the last cursor location when a file is opened unless this is a git commit.
au BufReadPost * {
	if line("'\"") > 1 && line("'\"") <= line("$") && &filetype != 'gitcommit'
		exe 'normal! g`"'
	endif
}

# Convert buffer to and from scratch.
command S {
    if &buftype == 'nofile'
        setl swapfile buftype= bufhidden=
    else
        setl noswapfile buftype=nofile bufhidden=hide
    endif
    echo printf('swapfile=%s buftype=%s bufhidden=%s', &swapfile, &buftype, &bufhidden)
}
Previously this was:

Code:
" Go to the last cursor location when a file is opened unless this is a git commit.
au BufReadPost *
	\ if line("'\"") > 1 && line("'\"") <= line("$") && &filetype != 'gitcommit'
		\| exe 'normal! g`"'
	\| endif

" Convert buffer to and from scratch.
command! S
    \  if &buftype is# 'nofile' | setl swapfile buftype= bufhidden=
    \| else                     | setl noswapfile buftype=nofile bufhidden=hide | endif
    \| echo printf('swapfile=%s buftype=%s bufhidden=%s', &swapfile, &buftype, &bufhidden)
All this mucking about with \ and \| was a right pain.

My vimrc is in Vim9Script (over here, if anyone's interested) and I've written some small plugins with it. It's not all that different from the old VimScript, but with a few "obvious" fixes and typing.

In general I prefer it over the Lua stuff Neovim did; I don't think Lua is a terrible language, but it's not a great language either IMHO, and if I look at what people need to do to call "nnoremap" in Lua then it's doesn't strike me as a great improvement.

Is it worth rewriting your vimrc in Vim9Script or Lua? Probably not; VimScript still works and isn't going away. The main reason I did last year was so that I had some real-world code to try Vim9Script out on so I could provide some feedback to Bram based on that. Also worth pointing out you can mix VimScript and Vim9Script (by using "function" or "def" for function definitions).
__________________
UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things.
Reply With Quote
  #5   (View Single Post)  
Old 21st October 2022
jkl jkl is offline
dat guy
 
Join Date: Feb 2014
Posts: 106
Default

While Vim9script has quite a few advantages over Vimscript (including performance improvements), Vim supports other languages just fine. If your script does not mostly contain editing commands, try Perl instead.
Reply With Quote
  #6   (View Single Post)  
Old 22nd October 2022
victorvas victorvas is offline
Real Name: Victor
Linux
 
Join Date: May 2019
Posts: 148
Default

Thanks!
Now I think I like Vim9Script more than Lua.
Reply With Quote
Reply

Tags
vim9 script

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning to script... RJPugh Programming 7 9th November 2014 08:04 PM
Apache: Old, out of touch, but worth it... : GitHub who? J65nko News 1 3rd December 2011 01:21 PM
ZFS, is it worth for my fileserver? gkontos FreeBSD General 7 21st November 2009 04:41 PM
Is it worth upgrading this laptops RAM TerryP General Hardware 4 17th January 2009 04:56 AM
Is such a course worth the time/money? TerryP Off-Topic 21 4th November 2008 08:05 PM


All times are GMT. The time now is 06:13 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick