When I try to use . .vimrc it gives and error:
bash: runtime! command not found
bash: syntax: command not found
bash: filetype: command not found
bash: filetype: command not found
It just randomly stopped working for no reason, all other dotfiles seem to work fine. The .vimrc contains this:
runtime! archlinux.vim
set number
set noswapfile
set nobackup
syntax on
set autoindent
set smartindent
set smarttab
filetype plugin on
filetype indent on
set incsearch
set hlsearch
It also gave an error inside a comment when it was there.
The . (or source) command is a bash command which reads a file (which should be a valid bash script) in the context of the current shell instance.
The .vimrc file is not a bash script, it's something that's read and processed by vim rather than bash.
It's no different to trying to compile C code with a Pascal compiler. The file content is not suitable for what you're trying to do with it. The .vimrc file should be automatically picked up next time you run a vim instance.
~/.vimrc is the runtime configuration file for vim i.e. the file will be read by vim when it starts and all the statements are vim specific.
As you are trying to source the file in bash, you are getting the errors as bash has no idea of the vim specific statements like runtime, syntax etc.
use vimorvi instead of source command to activate .vimrc.Because .vimrc is not *.sh like .bashrc and etc.
Related
I recently switched to fish shell from zsh and I have been encountering errors when I update my nvim config file
It appears the error comes when checking for the $TMUX environmet variable in a conditional statement. I added set shell=/bin/bash to the config solve the problem reloading vim but the error persisted.
Here is the error from when I try source ~/.config/nvim/init.vim:
~/.config/nvim/init.vim (line 99): Illegal command name “exists("$TMUX")”
if exists("$TMUX")
^
from sourcing file ~/.config/nvim/init.vim
called on line 1 of file -
in function “sv”
called on standard input
source: Error while reading file “/home/slick/.config/nvim/init.vim”
Confused because I am not very solid with vimscript and am not sure which language the conditional statement in the nvim config should be written in or how to resolve this error.
source ~/.config/nvim/init.vim
is a Neovim command, not a shell command. There's no reason whatsoever to expect your shell to understand Neovim's scripting language so running that command in your shell makes no sense at all.
Run it in Neovim, not in your shell.
Vim scripts that run external commands expect a POSIX compatible shell. Fish is explicitly not POSIX compatible. Add set shell=/bin/sh (or some other POSIX shell) to your vimrc.
I have this vim plugin
http://www.vim.org/scripts/script.php?script_id=4111
installed. I have included the following lines for the .vimrc:
autocmd BufRead,BufNewFile *.log set syntax=log4j
I am getting "autocmd unknown command"
when I am running
. .vimrc
from the bash
Please help.
The . command in Bash reads the argument as a Bash script; you're executing the Vim configuration as a Bash script. Of course, Bash doesn't know the autocmd command, and therefore complains.
Vim will automatically read in your ~/.vimrc on startup (cp. :help initialization). Just open a new Vim instance, and your new configuration will apply. You can ensure that the .vimrc has been read via :scriptnames (the file path should be listed at the start), or list your defined autocmd via :autocmd BufRead *.log
If you :edit somefile.log, you can verify that the syntax has been set via :setlocal syntax?
You don't need to run that command, once you will open any "*.log" file using "vim" the plugin will be used. if installed correctly.
I have a problem as follows:
I have a script which copies a log file from remote machine, does some modification on it and then opens it in vim, problem is vim doesn't auto recognize the file type (which outside of the script id does) – I need this for coloring the log.
Script as follows:
/usr/bin/rcp 14.1.61.10$node:/output/LocalLog_IPNode$node.log /export/home/fpd/tmp/tmp_local_log
chmod 777 /export/home/fpd/tmp/tmp_local_log/*
sed -i 's/[A-Z]\{4,8\}.*[oigus][kbdct][sel]\//---/g' /export/home/fpd/tmp/tmp_local_log/LocalLog_IPNode$node.log
vi /export/home/fpd/tmp/tmp_local_log/LocalLog_IPNode$node.log
My .vimrc:
au BufNewFile,BufReadPost LocalLog* set filetype=local_log
Note that the files opens in vim (if it helps the manual command ":set syntax=local_log" doesn't work either).
After exiting the script and manually opening the log everything works fine =(
Your problem is that the autocommand option is only availaible in vim and not vi.
So if this is available on your system, you should replace the last command line by :
vim /export/home/fpd/tmp/tmp_local_log/LocalLog_IPNode$node.log
Vim stands for "Vi Improved" and many options are only available in the latter.
To be sure you can do:
:help autocommand
It is always mentioned if the feature is vi or vim compatible.
I would like to use an existing DOS/Windows .bat script under a Cygwin bash shell. The .bat script creates a number of variables which need to exist after the .bat script ends.
This works, but the variables are not retained.
$ ./.phs_project_setup.bat .
It appears that this does not extend to sourcing a .bat script so that the variables it creates still exist in the environment.
$ . ./.phs_project_setup.bat .
-bash: #ECHO: command not found
-bash: SET: command not found
-bash: $'\r': command not found
-bash: REM: command not found
Any ideas on overcoming this obstacle?
What I have done is written the environment to a file, then iterated over the file using 'cygpath -u' on each value. Perhaps I have missed some, but it appears that cygpath will only change something that actually looks like a path. It does not change Oracle connect string for example; "user/pass#DB". I added 'export ' to the beginning of each line so that it can be sourced into a bash shell. It is not one step yet, but better.
Remember that Unix systems are generally case sensitive. cygwin's bash can run windows executables directly, but it's STILL case senstive. SET is not a valid bash command, while set is.
You can force it to source the file and try and run it, but it'll only be able to run shell built-in commands which have a 1:1 name correspondence to cmd commands. So set works, but #echo won't, because # means nothing to bash. Same goes for rem.
I would suggest trying to run the batch script using the batch interpreter (aka the COMSPEC environment variable, which is simply CMD) and then echoing out the environment it has set up as presented in this question: How I can use PowerShell with the Visual Studio Command Prompt?
You can then try and set up the environment in a similar fashion. Note that you may have a problem with the direction of slashes, drive names and other stuff like that
Sounds like you need to run the batch file and then start cygwin. If so, call the batch file from whatever file you use (cygwin.bat for example) to start cygwin. Then the variables should be available.
Alternatively, I've also moved the required bits into the proper unix configuration files to achieve the same results.
Currently, I'm using GEdit as my text editor for editing Ruby and Javascript source codes. I would like to give GVim a try to be my editor choice. I have tried to follow https://github.com/akitaonrails/vimfiles and few others instructions, but I don't get any luck, when I source ~/.vimrc, then I always get:
bash: /home/samnang/.vimrc: line 5: syntax error near unexpected token ('
bash: /home/samnang/.vimrc: line 5:call pathogen#runtime_append_all_bundles()'
Could you point me somewhere to get the instruction or configuration?
Environment: Ubuntu 10.10
Edit: If I don't source it, when I type vim or gvim, then I got:
Vim: Caught deadly signal SEGV
Vim: Finished.
Segmentation fault
You need to run source ~/.vimrc as an Ex mode command. That is, inside Vim itself, hit : and enter the command:
:source ~/.vimrc
Right now, you're running Bash's source command, which is entirely not what you want to do.
~/.vimrc is the configuration file for vim, and will automatically be read by vim when it launches in order to know how you want it set up. You can add your non-graphical vim commands, such as key mappings, abbreviations to ~/.vimrc/. In ~/.gvimrc you can add commands to set your colorscheme, the default number of columns and rows displayed at startup, etc.
If you aren't familiar with vim itself type vimtutor at the command-line and go through the tutorial.
To start gvim, type gvim at the command-line. To edit a file you can either open gvim, then use :e file/to/load in comman-mode, or do gvim file/to/load at the command-line. gvim supports multiple windows and tabs as does vim, so study those things to make the most use of them.
You can also try integrating Vim with eclipse if you want to bring IDE functionality to Vim (like projects, error highlighting, code completion, etc).
If you're interested check out the eclim project. It supports most of the modern languages, including Ruby, and I highly recommend it.
Try adding a .vim or vimfiles in your $HOME directory. If it still fails, add a file to the .vim directory. I did a
cd
mkdir .vim
cd .vim
touch .netrwhist
chmod g+w .netrwhist
I discovered this while learning about building your own syntax files at vim wikia creating your own syntax files