And today's #Vim #Neovim command "de jour" is
z=
to spell check the word under the cursor (because I write a lot of text)
Today's #Vim #NeoVim tip is a feature rather than a single command.
Use marks
=========
https://vim.fandom.com/wiki/Using_marks
Amongst other things, they help you jump around a file and move arbitrary lines of text with ease. e.g.
1. find 1st line of interest and create a mark with "ma"
2. Locate end of text block
3. Delete the text block with ":`a,.d"
4. Goto new location and hit "p"
A mark allows you to record your current position so you can return to it later. There is no visible indication of where marks are set. Each file has a set of marks identified by lowercase letters (a-z). In addition there is a global set of marks identified by uppercase letters (A-Z) that identify a position within a particular file. For example, you may be editing ten files. Each file could have mark a, but only one file can have mark A. Because of their limitations, uppercase marks may at firs
Saves messing about when you open a file you don't have permission to modify.
:w !sudo tee % > /dev/null
writes the file using sudo.
See https://stackoverflow.com/a/7078429/120371. Has Vim key map ('cause it's a PITA 2 look up the details every six months)
Want the same thing in neovim using lua?
1. Install ssh-askpass
2. Update your Neovim config
vim.env.SUDO_ASKPASS='/opt/homebrew/bin/ssh-askpass'
vim.keymap.set('c', 'w!!', ':w ! sudo -A tee /dev/null %')
YMMV
Today's #Neovim tip is something I learned last night from the comments section in a YouTube Short! (h/t to Fabio Ortega)
Add this Lua fragment to your config and by default Neovim will use the system clipboard.
vim.opt.clipboard='unnamed,unnamedplus'
The Video also contains some handy hints on how to use
viw
to yank the current word
not sure if that is better that
byw ...
Today's #Neovim tip is for people who want to give the editor a real try -- maybe because they used Vim in a past life.
They might even have tried some of the Neovim distributions, but been frustrated because there was too much "magic".
Instead you want to actually *learn* how to set up Neovim.
I found this YouTube playlist helpful.
https://youtube.com/playlist?list=PLsz00TDipIffreIaUNk64KxTIkQaGguqn
A git repo with example files is also provided, which I found a great way to start my own config.
Today's #Neovim tip is mainly for people writing blocks of text.
You can reformat unitidy paragraphs with the
gwap
command. I find it makes it slightly easier to read the content.
N.B.: If using markup, e.g. Markdown, the line breaks might not always be in right place.
#Vim #Neovim has many formatting commands and options, so RTFM is recommended
Today's #Neovim (and #Vim) tips are simple, but handy if you don't know.
How to insert text at the start of the buffer, or append text to the end.
1. Insert text at the head of the buffer.
1GO
And start typing. Explainer
1G -- move to 1st line
O -- open line above (uppercase o)
2. Append to the end of a buffer
Go
and start typing
G -- move to end (default for G)
o -- open line below
@alecthegeek It's a matter of taste I guess, but for 1 I prefer
ggO