New answers tagged

0

Unlike Maxin's answer, I'd recommend to use a ftplugin. They're really made to store the definition of filetype related mappings, commands, abbreviations, options, variables... While we shall use <buffer> with mappings and abbreviations, it's -b with commands. Now the problem is that you want to implement is quite complex. Vim main tool is regex. And ...


1

You cannot have a command started with lowercase letter, use :Stripdbg or :StripDbg To define a command available only in specific filetype you can define it in autocommand event with -buffer parameter: augroup cpp_group | au! au FileType cpp command! -buffer StripDbg call StripDbg() augroup end You have to implement StripDbg() function to do actual ...


3

I see that for some reason people like to use :bdelete to close buffers. That's a very strange practice, IMO. Let's recall what is that :bdelete all about. A buffer in Vim can 1) exist (bufexists() returns true); 2) be "loaded" (bufloaded() returns true), and 3) be "listed" (buflisted() returns true). Please, note that (2) and (3) are ...


2

If you are in a running vim instance and you need to add a new file you can use the argadd command (documented at :h :argadd). For example if I start vim with vim foo and use :argadd bar. I can then use argdo [mycommand to apply a command on all the files in the argument list. For more details on the argument list see :h arglist.


0

My recommendation is that you use BufRead to open the PDF and BufDelete to close it. Note that this should be set up at a global context, and not on the ftplugin for the tex filetype. Furthermore, you should match it by filename on *.tex (and other filenames you might want to match), rather than adding multiple per-buffer autocmd's attached to the filetype. ...


0

Try installing the lightline-bufferline plugin. The README constains instructions on how to show buffers in lighline.


2

An alternate method is to modify your alias (I prefer functions, so I’ll show both): # alias alias vim='vim +"setlocal readonly" ascii' # function vim () { command vim +'setlocal readonly' ascii "$@" } The issue here is I’m not sure if vim is ok with options/flags that come after the first file argument.


1

You will need to add to your vimrc an autocommand which will be executed every time you read the file and will be used to set the 'readonly' option on the file: augroup readonly autocmd! autocmd! BufReadPost ascii_img setlocal readonly augroup END See :h autocmd and :h 'readonly'


Top 50 recent answers are included