I usually prefer to write my website's paragraphs in LibreOffice. After finishing, I have to copy and paste the text to vim. I would prefer to keep "connected" this two editors, so what I write in LibreOffice is also in vim.
Is there any way to sync contents?
Solutions using Latex are also welcomed, since it is more hackable..
Add set autoread in your .vimrc. Then open the file both in vim and libreoffice, and vim will automatically reload the file if it detects changes.
BTW, if you are missing automatic line filling in vim, look at the formatoptions variable.
Related
I have enabled vim syntax on (in ~/.vimrc syntax on) and it works but only on files with a code in when I view them. When I create a new file with vim and write there some code - no syntax highlight. After saving this file and reopening with vim - syntax highlight works perfect.
I am using manjaro KDE.
When you open a new file without an extension (vim mynewfile) none of vim’s filetype detection mechanisms can recognize it (they all use either extensions or first-couple-of-lines heuristics, which don’t work here).
When you enter code and reopen the file, the line-checks for filetypes work, causing the syntax to be set correctly, causing highlights to apply.
You can always set syntax=mine (though set filetype=mine is better) to set it manually.
This problem shouldnt happen when you do vim some.c or similar, because the extension will force detection based on extension rules.
Vim must know how to highlight your syntax in order to actually highlight it. One way to do this, is for Vim to check the file name and sometimes inspect the contents of the file, and set the file type. The file type is then used to highlight the syntax.
To enable detection of the file type (and load plugin and indent files), add the following to your vimrc:
filetype on plugin indent
If Vim is unable to detect the file type, and you have not yet saved your file with a known extension, you can set the file type manually, like this:
:set filetype=html
Vim will then highlight the syntax of the file as HTML syntax.
More information is available in the help pages.
I would like for vim to show the tab header (tab line) even if only one file is open.
For example, I open a file using vim. Then, I use :tabnew to open another file in a vim tab. Vim then displays a nice tab header at the top of the file. I would like this tab header to always be displayed (i.e. even if only one file is open in vim).
Also, not really a fan of the airline plugins, so not really looking for those kinds of answers.
Yes sorry about that. I was doing :help tabline and didn't see anything. You just need to put set showtabline=2 in your vimrc
I use tabs for indentation in all my files. However, some bigger projects still use spaces, so I also need to follow those guidelines when I contribute.
This issue could easily be solved if the editor would detect the indent character used in the edited file, and use that one when e.g. autoindenting.
Sadly, vim forces spaces for indent, even when I am editing a file which otherwise only uses tabs.
How can I tell vim to always just use what the file is using (and use tabs if the file isn't using anything)?
I tried adding the following line (as I understand it, this should be forcing tabs - not exactly what I want, but better than inserting spaces everywhere) to ~/.vimrc and reopening the file I was editing, but this failed to take effect.
I am running vim-8.0.0386.
It looks like tpope/sleuth plugin is exactly what you want.
Otherwise, DetectIndent works too.
Clone the DetectIndent repo in your .vim/bundle/ directory (I use pathogen to install plugins), then open any file and type: :DetectIndent
Now shiftwidth, expandtab and tabstop should be adjusted to your file.
Here's another plugin recommendation: My IndentConsistencyCop plugin. It does not only detect the used indent setting, but also warns you if inconsistent settings are used within the same file.
Earlier, when I used open .py files in vim on ubuntu, they would be well formatted, with separate colours for separate segments of the program. Now, when I am using VIM on ubuntu, all the text in the .py file appears black. How can I correct this?
Formating in Vim means text formatting; e.g. indenting lists and breaking long lines. You're concerned about syntax highlighting, which is purely about the visual appearance of code.
First, it needs to be turned on.
:syntax on
does that.
Second, you probably want Vim to automatically detect the used language (e.g. Python) and choose the correct syntax plugin for you.
:filetype on
does that, though you usually enable more via :filetype plugin indent on.
To make these settings persistent, put them into your ~/.vimrc configuration.
Check man vim. In a nutshell, find a copy of a vimrc file, one might be under /usr/share/vim/ subtree. It may be named vimrc_example.vim. Copy to your home directory and rename it as .vimrc.
I use ":set ai sw=4" and ":set number" (and some other cmd) commands each time when I open any file in VIM.
For every new instance of VIM I have to enter set of commands. Is there any way where I can put these commands and VIM will execute it every time while opening any file like default settings.
Just paste those lines on the file ~/.vimrc and they'll be executed everytime VIM is openned. If it does not exist, create one.
Two recommendations:
Use a plugin that will auto-load .vimrc when you save it. Being confortable with editting .vimrc is very important. Building it up with your preferences and key-mappings as you learn VIM is one of the reasons it is so powerful.
Google now for some ready .vimrc setups as they override some not-so-optimal VIM configurations. For example, you probably won't want that annoying bell beep, among many other things.
You need to create a .vimrc file.
You should create it in your home directory.