Hot answers tagged

5

Just like this let @+ = &statusline Or like this call setreg("+", getbufvar("%", "&statusline")) Or even like this... if has("nvim") call provider#clipboard#Call("set", [[matchstr(execute("set statusline"), "=\@=.*"], "v", "+"]) endif


4

The primary difference is that readonly is per-buffer and write is global to vim. readonly is generally used when editing specific files that you do not have access to write (like /etc/fstab). Any buffer can be set to readonly if you want to prevent accidentally writing it to file. nowrite can be used to put vim into view-only mode, like pager utilities ...


3

Function defined in ftplugins In ftplugins we can define script local functions and global functions that are defined only when a buffer of the given filtetype is loaded. In the second case, the function is still global and can be hidden by any other script. In both cases, the functions will be redefined every time a new buffer of the same filetype is opened,...


3

Starting with Vim 8.2.2518, 'listchars' is a global or local-to-window setting. So you can use 'setlocal' to set a window-local 'listchars' setting.


2

In Bash and Zsh, a DEBUG trap can be used to chain a given set of commands or function to each issued command. Thus, trap 'clear; "$@"' DEBUG solves your problem. Presumably you do not want to do it manually every single time, nor to affect every interactive shells, only those in Vim's terminal buffer. In that case, the solution is to add this to ...


2

:set guicursor& should restore cursor defaults in GVim. Edit: To change the blink rate try using guicursor=a instead of guicursor=n like this : :set guicursor=a:blinkwait5-blinkon5-blinkoff5 This will ONLY work in GVim, not Vim.


2

There's a lot missing there. Ignoring the part after the first <CR> for now... First, there are some contexts, i.e. where a filename is expected, where you can use <cword> bare. But in many cases, including this one, you need to force it to be resolved or "expanded". That can be done with, naturally, expand('<cword>'). ...


2

On windows you should use ~/vimfiles/ instead of ~/.vim/. I would suggest to use ~/vimfiles/vimrc instead of ~/.vimrc too.


2

I think you are confusing buffers which are in memory representation of a file (:h buffers) and registers which are in memory places to store yanked and deleted text (:h registers). I think you would benefit from reading the doc on these topics and get a better understanding, you'll get less confusion in the long run. First a reminder on commands and motions:...


2

I suspect the answer is in set colorscheme blue which should just read colorscheme blue. Further reading on changing colours can be found in :h usr_06 and :h :colorscheme.


2

(Doesn't look like @filbranden or @AndrewHo-Lee are planning to answer this, so adding a Community Wiki answer with the diagnosis they figured out.) The problem turned out to be that 'compatible' was set when the mapping was defined. With this set, the 'cpoptions' setting contains the < flag, which means that Vim will not treat the <Esc> in the ...


1

Updated answer: Using :substitute to replace end/beginning of line with return got the results OP wanted. nnoremap o :s/$/\r/ <cr> nnoremap O :s/^/\r/ <cr> Original answer: I can't get just o to be remapped without a recursive error. But a reasonable compromise you might consider from this answer is to use oo for new line. This leaves single o ...


1

I think there are several points to address in your question: Firstly, if line("$") > 10 does test if the number of lines in the current buffer is greater than 10, or more precisely as :h line() explains that tests if the line number (line()) of the last line of the buffer ($) is greater than 10. Now there are a couple of things which can't work ...


1

To compile with javac filename.java, then use javac %. (+the backslash) If you want to execute java filename without the extension, then use java %< . Note, there is exists a :compiler javac that also change the 'errorformat' option, but it won't inject the current filename, you'd have to compile with :make %


1

This is quite easy thanks to auto commands. They allow you to specify vimscript to be run when certain events occur in Vim. There are event types for many different things that happen in Vim including loading and exiting/saving a buffer (file). You'll need something like this in your vimrc. augroup SpaceFix autocmd! autocmd BufReadPost,BufWritePre * :...


1

In theory you could give the same path to both plugins managers so that they install the plugins in the same directory: vim-plug call plug#begin('/path/to/your/plugins') vundle call vundle#begin('/path/to/your/plugins') In theory you could use one of the managers to install your plugins (PlugInstall for vim-plug or PluginInstall for Vundle), this plugin ...


1

The idiomatic answer is :%substitute/pat//gn Mass mentions searchcount() which returns a dictionary of interesting items. You'll need to set the last search pattern, though (e.g., / or write to @/), or pass pattern in the options to the function.


1

You can use: set tags=./tags; (You can also include the other entries from the default 'tags', such as just tags, which means a file with that name in the current directory, and also the uppercase variants, if those interest you as well. Use commas to separate different entries. The ; is not a separator.) This will look for a file named tags on either the ...


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