8 votes

Windows Subsystem Linux - Make VIM use the clipboard?

MAY 2023 SOLUTION The following worked for me (2023/05/15, WSL Ubuntu 20.04.5 LTS): Ensure your WSL has X11 support: https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps Ensure vim is ...
4b3eca728772390304b9e7984a69d7's user avatar
7 votes

Slight delay when switching modes in vim using tmux or screen

TL;DR: DO NOT use escape-time 0, but rather set it to a low value. In ~/.tmux.conf: set -s escape-time 50 # ~5-100. https://superuser.com/a/1809494/224906 Finish by either reloading your tmux config ...
Jonathan Wheeler's user avatar
2 votes

use sed to replace nbsp, 160, Hex 00a0, Octal 240, non-breaking space

Replace non-breaking space with space in a UTF-8 file The TLDR version of Thors answer sed -i 's/\xC2\xA0/ /g' filename
CervEd's user avatar
  • 157
2 votes

Vim enclose in quotes

:s/\(\%V\(.*\)\%V.\)/"\1"/ Based on the other answers, %V matches up to one character before the end of the selection. So an extra char matching is included.
Sam's user avatar
  • 21
2 votes
Accepted

How to `Ctrl+C` copy to the system clipboard using vscodevim extension in vscode/codium without using the `v` mode's system clipboard register `"*y`?

Seems like you just don't want vim to override the Ctrl key. To do this for any vim key bindings, you can just go to the vim settings (search for vim ctrl) and disable Vim: Use Ctrl Keys
willard's user avatar
  • 136
2 votes

Disable settings for files without extensions

autocmd BufNewFile,BufRead * if expand('%:t') !~ '\.' | set nonumber | endif expand('%:t') will get you the file name without full path. Then !~ '\.' will check that file name doesn't contain dot in ...
Eran Friedman's user avatar
2 votes
Accepted

How do I copy text from vim on a remote host in Terminal, to local MacOS clipboard?

SSH doesn't provide access to the macOS-specific IPC system that 'pbcopy' uses; it only provides the "text terminal" interface, and clipboard access is not typically part of that. Some ...
u1686_grawity's user avatar
2 votes
Accepted

Replace Template String with Current Date and Time in Vim

Or you could do it all in one place: nnoremap <leader>d :s/{{date}}\s*{{time24}}/\=strftime("%Y.%m.%d %H:%M:%S")<CR> where… you don't have to maintain a separate script, you ...
romainl's user avatar
  • 22.9k
2 votes

How to reveal a file in vim Netrw treeview?

This version works in neovim (written in lua + vimscript) and behaves like "show in project view" in Jetbrains Idea IDE. I mean it looks like it starts from the root of a project (pwd) and ...
Dmitry Surin's user avatar
2 votes
Accepted

Why neo vim is displaying $ at the very end of line and > at the beginnings of line

Those look like listchars, pseudo-characters used to more clearly see certain whitespace characters, such as tabs and newlines. Especially useful for distinguishing between tabs and spaces and making ...
8bittree's user avatar
  • 2,930
1 vote
Accepted

In [Neo]Vim, how do I display error messages from an external command used as a filter on the visual selection?

The use of 'xnoremap', as opposed to other '-remap' commands, means this only happens when a visual selection currently exists, automatically passing the selected text to the command, etc. Note that ...
romainl's user avatar
  • 22.9k
1 vote

How do I override a syntax's comment character in a modeline, in vim?

No, :help 'comments' is not taken into account by the syntax highlighting. Moreover, the pool of commands that are allowed in a modeline doesn't include :help :syn-match, which is the one you actually ...
romainl's user avatar
  • 22.9k
1 vote
Accepted

How do I set a version of vim as default?

The command to use is usually: update-alternatives --config vim On some systems it's just alternatives. And some systems can have a GUI installed called galternatives. Counter-intuitively the version ...
Heptite's user avatar
  • 19.9k
1 vote
Accepted

Getting python3-config path right for vim install

I found a solution that allowed me to install vim with the required support. What I did is setting two different flags pointing to my system python: ./configure --with-features=huge \ --enable-...
dherrera's user avatar
  • 121
1 vote

How do I get let &showbreak=' ' (two spaces between ticks) to work on modeline?

Well, seems that just typing my question answered it ;) /* vim: set breakindent formatoptions=l lbr showbreak=\ \ : */ Escapes.
Danathar's user avatar
1 vote

Disable settings for files without extensions

set number augroup noextension autocmd! autocmd BufNewFile,BufRead * call NoExtension() augroup END function! NoExtension() if !expand('%:e') && !&filetype setlocal ...
romainl's user avatar
  • 22.9k
1 vote

Disable settings for files without extensions

You don't need to match on filetype, you can directly match on the file name in BufRead and BufNewFile autocommands. Note I have no idea whether you can easily match "no dots", but this ...
u1686_grawity's user avatar
1 vote

Copying a filename on the same line to the end of the line

Here is a rather elegant method: f"yi"A <C-r>" Where… f" moves the cursor to the first " on the line, yi" yanks whatever is between the current double quotes to ...
romainl's user avatar
  • 22.9k
1 vote
Accepted

Copying a filename on the same line to the end of the line

There is no single best way. A way to do it is: :1,$s/\(file.*jpg\)\(.*\)/\1\2 \1 Another way is :map q 0t" yt"A ^[pj and pres q 3 times (note: enter ^[ as control-V escape) You can also ...
Ljm Dullaart's user avatar
  • 2,537
1 vote

How to copy from vim to clipboard on ubuntu 20.04

In case someone using nvim on Ubuntu 22 arrives here, this worked for me. Install xclip sudo apt install xclip remove default clipboard from vim vim.opt.clipboard = 'unnamedplus' You can now y/p ...
zing's user avatar
  • 211
1 vote

Is there any simple tmux/screen alternative?

If you want to deal with unreliable connections, try mosh: https://mosh.org/ If you just want more terminal sessions and detach/reattach, try byobu: https://www.byobu.org/ For a possibly simpler ...
Liam Proven's user avatar
1 vote

Vim isn't recognizing my vimrc file

Running vi --version showed VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Feb 28 2023 00:00:00) But, it also later showed: system vimrc file: "/etc/virc" user vimrc file: "$HOME/...
ergohack's user avatar
  • 121
1 vote

Use project or file specific spellfiles in vim

dialect.vim provides an interesting alternative. The plugin binds zG and zW to ./.dialect.{encoding}.add. file that functions similarly to the internal word list.
Konrad's user avatar
  • 767
1 vote

How to exit help in vim

I combined previous answers to get: autocmd FileType help noremap <buffer> q :bd<CR> or in lua: vim.api.nvim_create_autocmd( "FileType", { pattern = {"help"...
pete-may's user avatar
1 vote

Hiding vim command-line when it's not being used?

As stated earlier, you can do set cmdheight=0 in neovim (vim.opt.cmdheight=1 if you use lua). You'd still be able to interact with cmd input when you type ":". The issue is that some ...
aghriss's user avatar
  • 11
1 vote

When editing an existing file with Vim, will it replace or change that file?

I've observed that the option writebackup and whether the edited file has more than one hard link changes the behavior of Vim in that regard. The following results pertain to Vim 9.0.2167 and Neovim 0....
Matthias Braun's user avatar
1 vote

Vim: How do you efficiently search for text?

Refining your search pattern interactively (Works when 'incsearch' is active.) Press /, start typing the search pattern. CTRL-L add the next character of the highlighted match to the search pattern. ...
Gebb's user avatar
  • 111
1 vote

Install Vim in Cygwin

gvim -v runs vim/vi without GUI, just like the vim improved / enhanced CygWinX vi is vim minimal and it is a very striped out version of vim the work around to have a fully working version of it is ...
Marcos Cesar Da Silva's user avatar
1 vote

VIM: How do you get the last ex command you used?

I'd like to complement @Heptite's answer. To merely copy the command line into system clipboard (the register +), just type :let @+ = @:, assuming your vim support +clipboard feature, according to @...
Kevin's user avatar
  • 11
1 vote

How to jump to the beginning or end of line in vim + OS X

As of Nov'23, these simple shortcuts work for me with vim (insert mode) open in Terminal app. This works OOTB, no editing of rc files etc. is needed. Shift+left/right - move word by word Fn+Shift+left/...
Denis P's user avatar
  • 111

Only top scored, non community-wiki answers of a minimum length are eligible