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

How to include forward slash in vi search & replace

Here are two ways: escape the / which is the default substitute separator: :s/usrbin/\/usr\/bin use another substitute separator, e.g., using the hash # character: :s#usrbin#/usr/bin. Note that there are characters that you can’t use as a separator: “, \, | You can review this in the help subsystem using :h pattern-delimiter

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

Make Vim show ALL white spaces as a character

As others have said, you could use :set list which will, in combination with :set listchars=… display invisible characters. Now, there isn’t an explicit option which you can use to show whitespace, but in listchars, you could set a character to show for everything BUT whitespace. For example, mine looks like this :set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< so, … Read more

Why do Vim experts prefer buffers over tabs? [closed]

As ZyX said on #vim, this question sounds like “Why do Vim experts prefer tasty over warm?”. “Vim experts” don’t prefer buffers over tabs: they use buffers as the file proxies they are and tab pages as the workspaces they are. Buffers and tab pages have different purposes so preferring one to the other makes … Read more