Are we talking vim trix? Oh my god I love talking vim trix.
Neovim has an integrated terminal. One thing I like doing is making an autocommand that, whenever I save the file, runs a specific test suite in the terminal. It’s like a lightweight test runner.
Another Neovim thing: set inccommand=nosplit. This shows you realtime what an :s command will do, and they’re working on extending it to normal and g.
One thing you might not have realized about the undo: it’s not a list of changes, it’s a tree. You can navigate it both chronologically and changewise and jump between different branches. I use the mbbill//undotree plugin to visualize it. Absolutely fantastic.
kshenoy/vim-signature shows marks on the sidebar and lets you add marks like ! or ? to your file.
I’ve been doing some weird exobrain experiments too, but those aren’t anywhere near ready to share yet =)
you should never use set from an autocmd, as that will affect all buffers, not just the YAML one, so if you have a YAML and Python buffer open then both will be affected; yikes!
Always use setlocal (or setl for short) if you want to set something specific to the bufer.
In addition, it’s good practice to keep autocommands in an augroup:
augroup my-yaml
autocmd!
autocmd FileType yaml set tabstop=2 shiftwidth=2
augroup end
otherwise reloading the file means set will get run twice (try it: :source ~/.vim/vimrc | au FileType yaml) For this set (or setl) command it’s not a huge deal, but for other stuff there’s a large performance penalty. Also see: Why should I use augroup?.
source ~/.vimrc
You can use ~/.vim/vimrc as well; that has worked since Vim 7.3.something (a long time). This way all your vim files are in one directory.
I agree the undo history is very useful, but it’s annoying that it it’s easy to accidentally use it. I wrote a little plugin which, IMHO, improves the UX of it a lot: https://github.com/Carpetsmoker/undofile_warn.vim
you also need to create that undodir manually, otherwise it won’t work. This is what I have:
set backupdir=$HOME/.vim/tmp/backup " Set/create directory to keep backup, swap, and undo files.
set directory=$HOME/.vim/tmp/swap
set viewdir=$HOME/.vim/tmp/view
set undodir=$HOME/.vim/tmp/undo
if !isdirectory(&backupdir) | call mkdir(&backupdir, 'p', 0700) | endif
if !isdirectory(&directory) | call mkdir(&directory, 'p', 0700) | endif
if !isdirectory(&viewdir) | call mkdir(&viewdir, 'p', 0700) | endif
if !isdirectory(&undodir) | call mkdir(&undodir, 'p', 0700) | endif
Newer Vim versions won’t error out if the directory already exists, so I suppose this can be a little simplified now.
For Insert mode completion I think the future is Language Server Protocol (LSP); this way we’ll have one LSP client for Vim that will work for everything (provided there is a lsp). I am currently using vim-lsc, and it works very well. There are many more options (ALE also includes an LSP client, for example).
For over 10 years I’ve been a very ardent (some would say zealous) supporter of (n(eo))vim, carefully tweaking and updating my configuration to be as barebones or as feature-full as I needed and desired, and spreading the gospel of Vim to all those that would listen.
About 6 months ago I tried out the vimagit plugin, which I found immediately useful. I then realized that this plugin was based off of the emacs magit package, which intrigued me further, and that sent me down a rabbit hole of trying out emacs with evil-mode (gasp! horror!).
I’ve been a (spac)emacs+evil user since that day. It combines all of the muscle memory that I know and love (complex word motions, edit sequences, etc.) from vim, and gives me a TUI-based editor that has all all of the project/IDE based functionality that I had always spent far too much time configuring and fighting against in vim. I just don’t have the energy for that anymore.
If you’re like me and love vim, and are looking to “revamp” your setup like the post describes, give Spacemacs a try. There are others, too (e.g. doom-emacs), and there are of course the DIY build-it-yourself setups that you can tinker with endlessly, but I was completely astounded by how intuitive and how short of a learning curve spacemacs with evil mode was.
Yes, I saw magit from my colleague and that’s how I discovered vimagit. I’ve heard good things about evil mode but I’m not ready to try yet, though you’re sound convincing.
The emacs magit package was the primary reason I tried the switch. After watching a few instructional videos & reading some documentation, I had to try it out. It’s every bit as good as I had hoped for.
Using emacs+evil with some project-level plugins like helm for autocompletion and projectile for navigation has been fantastic. It took me a few days to get used to some of the different key combinations to navigate around, but that was quite minimal in the grand scheme of things.
IMO, Vim help is the most underestimated feature of Vim
I have been using vi/vim since .. 1999(?) and it took me a looong time to get beyond beginner. The fact that we still have to learn vim tips by sharing configs and articles speaks to how poorly the documentation is presented. My primary sources for going beyond beginner were vimcasts and more recently greg hurrell’s screencasts.
It’s fine that help is built in for powerusers, but in a typical terminal window, :help gets half the width or height. Good luck reading new material like that while trying it out. I have never been able to find an up-to-date vim documentation in HTML format. I just now discovered that neovim has documentation available in browsable HTML format.
Also, I cannot find Vim changelogs anywhere. I learned about packs and async by accident. I still don’t know how to use async. Looking at neovim.org, I see the latest news is from 2017, so I assume nothing worthwhile has happened since then.
You will probably want to include releases with changelogs under the news headline. For example, on OpenBSD.org, it only takes one click from the front page to get a list of changes in the most recent release.
Also, I cannot find Vim changelogs anywhere. I learned about packs and async by accident.
The Vim changelogs are within its help system, linked from within the Versions section in the top-level help. The most recent file describing changes is at :help version8.txt – it describes packages, async I/O, and more in its New Features section. (Note that Vim’s async implementation works differently from NeoVim’s.)
One of the best Vim (Neovim) articles I’ve read. I’ve begrudgingly stuck with Vim (8) instead of Neovim. Is there really a case to switch to Neovim? Right now, I messed up my .vimrc one day. Didn’t want to fix it (or lazy or sick of configuring and tweaking), so here I am using Sublime for the last few months instead. I tried VS Code, but only use it at home on my side projects in Go, Python, and/or C#. I use Sublime right now for everything else at work (Ruby/Rails since VS Code Ruby/Rails is something to be desired).
I’d really like to just get back into and use Vim (or Neovim) since it’s reliable. Available. Free. Open source. And does only what I need. Nothing more.
Are we talking vim trix? Oh my god I love talking vim trix.
Neovim has an integrated terminal. One thing I like doing is making an autocommand that, whenever I save the file, runs a specific test suite in the terminal. It’s like a lightweight test runner.
Another Neovim thing:
set inccommand=nosplit
. This shows you realtime what an:s
command will do, and they’re working on extending it tonormal
andg
.One thing you might not have realized about the undo: it’s not a list of changes, it’s a tree. You can navigate it both chronologically and changewise and jump between different branches. I use the
mbbill//undotree
plugin to visualize it. Absolutely fantastic.kshenoy/vim-signature
shows marks on the sidebar and lets you add marks like!
or?
to your file.I’ve been doing some weird exobrain experiments too, but those aren’t anywhere near ready to share yet =)
I haven’t found a good use for embedded terminal but I think that’s because I use i3 and terminals everywhere.
Could you elaborate on your terminal case? Maybe share the autocommand?
Good article; I have a few nitpicks :-)
you should never use
set
from anautocmd
, as that will affect all buffers, not just the YAML one, so if you have a YAML and Python buffer open then both will be affected; yikes!Always use
setlocal
(orsetl
for short) if you want to set something specific to the bufer.In addition, it’s good practice to keep autocommands in an augroup:
otherwise reloading the file means
set
will get run twice (try it::source ~/.vim/vimrc | au FileType yaml
) For thisset
(orsetl
) command it’s not a huge deal, but for other stuff there’s a large performance penalty. Also see: Why should I use augroup?.You can use
~/.vim/vimrc
as well; that has worked since Vim 7.3.something (a long time). This way all your vim files are in one directory.I agree the undo history is very useful, but it’s annoying that it it’s easy to accidentally use it. I wrote a little plugin which, IMHO, improves the UX of it a lot: https://github.com/Carpetsmoker/undofile_warn.vim
you also need to create that undodir manually, otherwise it won’t work. This is what I have:
Newer Vim versions won’t error out if the directory already exists, so I suppose this can be a little simplified now.
For Insert mode completion I think the future is Language Server Protocol (LSP); this way we’ll have one LSP client for Vim that will work for everything (provided there is a lsp). I am currently using vim-lsc, and it works very well. There are many more options (ALE also includes an LSP client, for example).
At any rate, here’s my ~/.vim directory, in case you’re interested: https://github.com/Carpetsmoker/dotfiles/blob/master/vim/
No, the article is about Neovim, which automatically creates ‘undodir’ and ‘directory’ (swapfile directory) if needed. But not ‘backupdir’.
mkdir(&directory)
(andmkdir(&undodir)
, etc.) isn’t advisable for most users, because those options are comma-separated lists.I didn’t want to emphasize on Neovim and I believe most of the things I use can be applied to Vim.
P.S. Thanks for Neovim!
Thanks for the nitpicks, I’ll definitely check augroup and setlocal.
For over 10 years I’ve been a very ardent (some would say zealous) supporter of (n(eo))vim, carefully tweaking and updating my configuration to be as barebones or as feature-full as I needed and desired, and spreading the gospel of Vim to all those that would listen.
About 6 months ago I tried out the vimagit plugin, which I found immediately useful. I then realized that this plugin was based off of the emacs magit package, which intrigued me further, and that sent me down a rabbit hole of trying out emacs with evil-mode (gasp! horror!).
I’ve been a (spac)emacs+evil user since that day. It combines all of the muscle memory that I know and love (complex word motions, edit sequences, etc.) from vim, and gives me a TUI-based editor that has all all of the project/IDE based functionality that I had always spent far too much time configuring and fighting against in vim. I just don’t have the energy for that anymore.
If you’re like me and love vim, and are looking to “revamp” your setup like the post describes, give Spacemacs a try. There are others, too (e.g. doom-emacs), and there are of course the DIY build-it-yourself setups that you can tinker with endlessly, but I was completely astounded by how intuitive and how short of a learning curve spacemacs with evil mode was.
Yes, I saw magit from my colleague and that’s how I discovered vimagit. I’ve heard good things about evil mode but I’m not ready to try yet, though you’re sound convincing.
The emacs magit package was the primary reason I tried the switch. After watching a few instructional videos & reading some documentation, I had to try it out. It’s every bit as good as I had hoped for.
Using emacs+evil with some project-level plugins like helm for autocompletion and projectile for navigation has been fantastic. It took me a few days to get used to some of the different key combinations to navigate around, but that was quite minimal in the grand scheme of things.
One of these days I’m gonna bite the bullet and try out emacs. I have so much invested into my vim environment that it scares me to leave….
FYI, 99% of the settings from vim-sensible are already the defaults in Neovim.
Shhh, don’t tell Tim Pope…
Someone SHOULD tell Tim Pope (much respect for all his good work) given some of his Tweets around neovim’s relevance :\
I have been using vi/vim since .. 1999(?) and it took me a looong time to get beyond beginner. The fact that we still have to learn vim tips by sharing configs and articles speaks to how poorly the documentation is presented. My primary sources for going beyond beginner were vimcasts and more recently greg hurrell’s screencasts.
It’s fine that help is built in for powerusers, but in a typical terminal window, :help gets half the width or height. Good luck reading new material like that while trying it out. I have never been able to find an up-to-date vim documentation in HTML format. I just now discovered that neovim has documentation available in browsable HTML format.
Also, I cannot find Vim changelogs anywhere. I learned about packs and async by accident. I still don’t know how to use async. Looking at neovim.org, I see the latest news is from 2017, so I assume nothing worthwhile has happened since then.
Plenty has happened. Newsletter is coming soon.
There’s also a releases page that makes it pretty clear that several major releases have occurred, not to mention the pulse page.
Thanks.
You will probably want to include releases with changelogs under the news headline. For example, on OpenBSD.org, it only takes one click from the front page to get a list of changes in the most recent release.
I agree that Vim documentation is hard for newcomers. But for me it was invaluable.
Also, I’ve used https://vimhelp.org/ as up-to-date online doc. Currently it’s built for Vim 8.1.
The Vim changelogs are within its help system, linked from within the Versions section in the top-level help. The most recent file describing changes is at
:help version8.txt
– it describes packages, async I/O, and more in its New Features section. (Note that Vim’s async implementation works differently from NeoVim’s.)One of the best Vim (Neovim) articles I’ve read. I’ve begrudgingly stuck with Vim (8) instead of Neovim. Is there really a case to switch to Neovim? Right now, I messed up my .vimrc one day. Didn’t want to fix it (or lazy or sick of configuring and tweaking), so here I am using Sublime for the last few months instead. I tried VS Code, but only use it at home on my side projects in Go, Python, and/or C#. I use Sublime right now for everything else at work (Ruby/Rails since VS Code Ruby/Rails is something to be desired).
I’d really like to just get back into and use Vim (or Neovim) since it’s reliable. Available. Free. Open source. And does only what I need. Nothing more.
Try https://github.com/lunixbochs/actualvim , which is a Sublime plugin that embeds Neovim quite seamlessly.
Nothing on language servers. There’s a few different plugins/clients, and Neovim even has an official, built-in one coming too.
I’m currently using https://github.com/autozimu/LanguageClient-neovim because I believe it was the best/only one at the time I was looking.
I haven’t spent the time to compare the other new ones.
You kicked me into my yearly vim re-do. Congratulations.
I like the article but a lot of the screenshots are broken :(
Forgot to commit them, it’s fixed now. Thanks for pointing!