Best way to insert timestamp in Vim?

To make it work cross-platform, just put the following in your vimrc: nmap <F3> i<C-R>=strftime(“%Y-%m-%d %a %I:%M %p”)<CR><Esc> imap <F3> <C-R>=strftime(“%Y-%m-%d %a %I:%M %p”)<CR> Now you can just press F3 any time inside Vi/Vim and you’ll get a timestamp like 2016-01-25 Mo 12:44 inserted at the cursor. For a complete description of the available parameters … Read more

Traversing text in Insert mode

While it may make sense that you should be able to use the h j k l keys to traverse the editor in insert mode, but that is actually not the way Vim is intended to be used! There are many commands that Vim provides to make editing faster and easier. The right way is … Read more

Move entire line up and down in Vim

If I want to swap one line with the line above I usually do the following ddkP Explanation dd will delete the line and add it to the default register. k will move up a line (j would move down a line) P will paste above the current line

How to paste over without overwriting register

Use the following: xnoremap p pgvy this will reselect and re-yank any text that is pasted in visual mode. Edit: in order this to work with “xp you can do: xnoremap p pgv”@=v:register.’y'<cr> v:register expands to the last register name used in a normal mode command.

How do I use vim registers?

Registers in Vim let you run actions or commands on text stored within them. To access a register, you type “a before a command, where a is the name of a register. If you want to copy the current line into register k, you can type “kyy Or you can append to a register by … Read more