I have this line of code in .vimrc :
au BufRead *.xlsx exec "echo 'xxx'"
And when I open a .xlsx file in vim 7.3 ( I know it's weird to open such a file in vim ), it did echo xxx to me.
But after I upgraded vim to 7.4 and did the same thing, it didn't echo anything to me now.
I've tested it in several machines getting the same result, so I wonder what feature in 7.4 causes this , and what can I do to make it echo what I want like before?
I see that you've figured out the culprit already in the comments (thanks Ben!).
This is caused by version v27 of the zip plugin that ships with Vim 7.4. Its change log reads:
(Jason Spiro) provided a lot of new extensions that are synonyms for .zip
And in fact, the new MS Office file formats (ending with x) are all XML-based ZIP files (whereas the previous ones were in a proprietary binary format).
Fortunately, the plugin allows to override the default file extensions that are considered. You can remove the Office ones from the following list and put that into your ~/.vimrc:
:let g:zipPlugin_ext= '*.zip,*.jar,*.xpi,*.ja,*.war,*.ear,*.celzip,*.oxt,*.kmz,*.wsz,*.xap,*.docx,*.docm,*.dotx,*.dotm,*.potx,*.potm,*.ppsx,*.ppsm,*.pptx,*.pptm,*.ppam,*.sldx,*.thmx,*.xlam,*.xlsx,*.xlsm,*.xlsb,*.xltx,*.xltm,*.xlam,*.crtx,*.vdw,*.glox,*.gcsx,*.gqsx'
Related
I am trying to learn how to use Vim. Apparently I have failed at the first hurdle since Vim (certainly on my computers) cannot open files from within itself. I know this must somehow be a mistake on my part since how can Vim still be around with such a flaw??
Anyway I have searched for the last day or so with no solution.
I have tried:
:e .
And Vim helpfully tells me that: "." is a directory. I was under the impression that this command would open a file browser in current directory, but it doesn't.
Similarly I have attempted other commands:
:Ex
:Explore
:Sexplore
:Sex
:Vexplore
:Vex
:Hexplore
:Hex
I have tested these from How do you open a file from within Vim? but nothing suggested there works.
All of these produce: E492: Not an editor command: <insert any of the above commands here>.
I am left with the conclusion Vim can't open files unless Vim is called from the terminal and the file is passed as an argument or the files happen to be in the current directory (where ever that may be) and you know the file's name.
Can someone help? I would like to be able to open files in other directories and list them but for the life of me nothing is working despite every guide I have read saying it would.
Thanks.
At the request from Zaffy this question has been solved.
At Robby Cornelissen's prompting I checked the MX's Linux's package manager and found that vim-common was installed but weirdly not vim. Once I'd installed vim :e . worked and I can now navigate the filesystem.
I have no idea the difference between vim-common and vim or the reason for the separate packages; Robby Cornelissen suggests that vim-common is probably a minimal or tiny version of vim.
I use script files with gvim to set syntax to html for files that don't have the extension 'html', but which contain html.
Eg script file contains 'set syntax=html'.
When file is edited: gvim -S scriptfile.txt myfile.txt, the syntax highlighting no longer appears. I say 'no longer' because I've been doing this for years and suddenly (Win10, Vim 8.1) it has stopped... Within the edit, ':set' returns 'syntax=html' - but no syntax highlighting. Must have screwed up something subtle, but what? Thanks for any help.
Went back to the default "c:\Program Files (x86)\vim_vimrc", instead of copying mswin.vim to that location. All's well.
I was looking to get into learning a text editor for programming. However, I've quickly run into a little snag that I can't seem to find a solution to.
I have modified my /home/user/.nvimrc file to add some plugins and I can load it using :source ~/.nvimrc, however, it never loads automatically. :scriptnames shows a list of scripts in /usr/, but mysteriously absent from the list is the .nvimrc file in my home directory. Again, I can load it in the command line, but I'd like to not have to use :so ~/.nvimrc every time I open a file.
I am not using sudo to run vim.
How can I solve this problem? Is this something everybody has to do?
Could be this issue: https://github.com/neovim/neovim/issues/3530
Summary:
New location is ~/.config/nvim/init.vim
To keep ~/.nvimrc you can source it from the new location:
mkdir -p ~/.config/nvim
echo 'source ~/.nvimrc' > ~/.config/nvim/init.vim
Instead of referring to your rc file directly, consider using $MYVIMRC:
:e $MYVIMRC
:source $MYVIMRC
Reference: Learn Vim the Hard Way/Editing your vimrc
:help config lists the paths for each OS:
Unix ~/.config/nvim/init.vim (or init.lua)
Windows ~/AppData/Local/nvim/init.vim (or init.lua)
$XDG_CONFIG_HOME $XDG_CONFIG_HOME/nvim/init.vim (or init.lua)
Quiet simply I am trying to add new files to my repository, my command goes like this:
svn add * --force
but this produces:
svn: File 'install/config.xml.php' has inconsistent newlines svn:
Inconsistent line ending style
The thing is that this file is not yet under version control, so when I try to propdel or anything similar it doesn't work.
I am sure this file is not under version control because svn status shows this:
? install/version
? install/config.xml.php
I have already enabled the autoprops in svn default config but this did not help.
Any ideas?
Btw: this is a server, so no GUI.
vim makes it easy to force line endings to entirely CRLF or entirely CR.
:set ff=unix
:wq
d2u, dtox, dos2unix, are some names for simple utilities that are often installed on systems to do this task. You could also use the standard tr(1) utility:
tr -d '\r' < input > output
While working on Windows OS use Notepad ++:
Edit -> EOL Conversion.
- Windows Format
- UNIX/OSX Format
- Old Mac Format
You have current format information in the status bar.
I am learning to use Vim and I want to have a portable version on my USB to edit my code here everywhere. I knew there are a portable version of Vim, but while i was searching for that version I found here an interesting comment:
I wouldn’t reccomend using portable vim. It is unmaintained, and vim can be made portable by just adding a few options in your vimrc.
I got intrigued. I would be glad to have the desktop version of GVim in my USB, but those lines aren't mentioned. Someone knows which vimrc options he is talking about?
*PD: I'm not a native English speaker, so If there are some writing errors, don't hesitate to tell me please :)
There are portable versions of vim that seem to be maintained, but personally I've never found a particular need for them: the standard Vim is portable enough for my needs.
Create a directory on your USB stick (let's assume that it's E: when you're creating it):
E:\vim
Add two folders:
E:\vim\vim73
E:\vim\vimfiles
Copy the contents of C:\Program Files\vim\vim73 (or wherever it's installed) into E:\vim\vim73 and take your vim configuration files (if you have any) and put them in E:\vim\vimfiles. Copy your vimrc to E:\vim\_vimrc.
Now put the USB stick in another PC (let's assume it mounts it as F:). Open Windows Explorer, navigate to F:\vim\vim73 and double click on gvim.exe. It will open the Vim GUI and load your configuration.
To keep the local and portable vim configurations matching, I'd recommend sticking the vimfiles directory under version control (also allows you to easily try out new plugins and then 'revert' to get rid of them if you don't want them) and having a checkout on the USB stick and another one on the PC. If you move your _vimrc to vimfiles\vimrc and replace your _vimrc with the following, it will keep vimrc version controlled with all the plugins and configuration:
" _vimrc - Links to the vimrc in the vimfiles directory
runtime vimrc
You can do the same with _gvimrc if you have one.
Despite all the portable forks and complicated HOWTOs, making plain vim portable is pretty easy, actually I can't imagine it could get easier as you only need single line in config. At least on Windows, but I expect it to work elsewhere as well, let me know if I am wrong.
tl;dr
let $HOME=$VIM
$VIM variable is relative to the executable and points to parent directory (Z:\vim-portable in our case).
the unnecessarily long version
Let's mix in directory structure and pathogen.
Unpack the zips in vim74 dir:
vim74w32.zip (cmd version)
gvim74.zip (GUI version)
vim74rt.zip (runtime files)
Create your _vimrc config file and insert:
" Make vim portable.
let $HOME=$VIM
" Load and run pathogen.
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
git clone pathogen into vimfiles/bundle dir. You could also just autoload pathogen, but I like it this way.
And the tree looks like this:
Z:\vim-portable
| _vimrc
|
+---vim74
| | gvim.exe
| | vim.exe
| +---autoload
| +---colors
| +---compiler
| +---doc
| +---ftplugin
| +---indent
| +---keymap
| +---lang
| +---macros
| +---plugin
| +---print
| +---spell
| +---syntax
| +---tools
\---vimfiles
\---bundle
\---vim-pathogen
gVimPortable - Last updated 2019-12-18.
I didn't have to create a new _vimrc with "runtime vimrc" in it. I just keep my _vimrc in the same directory and vimfiles/ and vim73/. On starting vim73/gvim.exe - it automatically reads the _vimrc
Actually it is very easy to create such version for portable gvim.
How to create portable gvim by dropbox/skydrive
Install gvim normally and configure it correctly.
Move it to dropbox with whole folder.
Create right system menu item to quick open gvim. It is very convenient.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT*\Shell\Edit with Vim]
#="Edit with &Vim"
[HKEY_CLASSES_ROOT*\Shell\Edit with Vim\command]
#="\"C:\Users\xxx\Dropbox\Vim\vim74\gvim.exe\" -p --remote-tab-silent \"%1\" \"%*\""