Hot answers tagged

6

Generally speaking, that's exactly what the :noautocmd command modifier is for. Just prefix your command with that and all autocommands should be disabled for just the run of that command. :noautocmd w Of course, this is the scorched earth approach. If there are other autocommands that you need to keep enabled and you're trying to ignore just the one you ...


5

What eventually worked for me was: vim -b <filename> Then in vim: :set noeol :wq Credit


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

If you are working on a file that is not in the current working directory, and you want to save it under a new name in that directory, you can use the following: execute 'saveas' expand('%:h') . "/new-file-name" The execute command allows you to use an argument to saveas that is not a literal string. expand('%:h') gets the relative path of the ...


2

Just ignore all errors from LanguageClient silent! call LanguageClient#textDocument_formatting_sync() Note: the last error message is still available as echo v:errmsg.


2

:wa and :wqa will write all changed buffers; from :help :wqa: :wqa[ll] [++opt] :wqa :wqall :xa :xall :xa[ll] Write all changed buffers and exit Vim. If there are buffers without a file name, which are readonly or which cannot be written for another reason, Vim will not quit. Since your ...


1

Although an async alternative would be better, this one is pretty neat. The problem as comments pointed out was the quotes. augroup renderRmd | au! autocmd BufWritePost *.Rmd call Render() augroup end function! Render() abort :tabnew | te Rscript -e "rmarkdown::render(<afile>:p:S)" :tabprev endfunction This works with :w and ...


1

You can have your autocmds check what the &filetype is when making a decision. For something as short as checking that it's different from 'help' you might be able to go with a one-liner (use | to separate commands), for something more complex go with a separate :function (to help keep your sanity!) For your specific case: set viewoptions-=options ...


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