vi refusing syntax on - syntax

I am not working on my normal computer and only have access to Ubuntu Lucid 10.04. I have added an alias to my .bashrc file to create the alias
alias vi='vim'
I have then added the following 3 lines to my ~/.vimrc file.
syntax on
set nu
set ai
vi is refusing to accept the syntax on command and when I do a :version syntax has a - rather than a + in the past I believe I have only had to take the above steps to get out of legacy mode and to switch syntax highlighting on.

:version is showing you what options Vim was compiled with. So if it says -syntax, it means you're running a Vim that has no support for syntax highlighting, not that syntax highlighting is turned off.
If you have no control over the system, your best bet is to just install your own Vim (with support for all your favorite features) into your user directory, and alias vi to run that version.

Related

Vi syntax-highlighting after executing vi within bash script

I created this Stackoverflow account only for asking this question:
Is there a way to tell Vi to do syntax-highlighting when executing it from within a script like this:
#!/bin/bash
vi /path/to/script.sh
I was trying things like this and other stuff like sudo su - in order to reset the environment, but nothing worked..
Any chance a to make it work(preferably without editing the .vimrc)?
Thanks :)
You can run a command when you launch vi after the file is loaded:
vi -c "syntax on" /path/to/script.sh
That should turn on syntax highlighting
On most Unix systems, vi is not vi itself, but a symlink to /etc/alternatives/vi, which itself is a symlink to a vi-alike editor. You can find out which editor that is with the command
ls -l /etc/alternatives/vi.
Fabio Almeida clearly has vim, which has syntax highlighting, but you might have an editor like nvi, which doesn't. To use it, you would have to install a different editor (like vim).

Stata is not seeing environment variables needed for ODBC connection

I use the Simba ODBC driver (2.3.2) to connect Stata to BigQuery from my macOS laptop. I recently upgraded to Big Sur (11.2.1) and lost the ability to do this.
I am using iODBC and I am able to test the DSN successfully. I was also able to get everything to work in macOS 10.15.7 just fine (on a different machine).
The problem appears to be that Stata is not seeing the DYLD_LIBRARY_PATH environment variable that I have defined in my .bash_profile profile according to the driver configuration instructions.
In Stata, I get this error:
. odbc list
The ODBC file libiodbc.dylib could not be found on this system.
Setting the unix LD_LIBRARY_PATH environment variable may correct this error.
r(680);
I am able to set this in bash:
$ echo $DYLD_LIBRARY_PATH
:/usr/lib/:/usr/local/
But that does not seem to work since:
$ printenv | grep 'DYLD'
is empty. I suspect something in Big Sur is preventing this environment variable from being set.
Happy to try anything to fix this.
To fix this, you need to disable SIP, which keeps the $DYLD_LIBRARY_PATH environment variable from being defined without issuing a warning.
To disable SIP:
Restart your computer in Recovery mode by holding down Command(⌘)-R once it powers off. Press that until you see the Apple icon and a progress bar.
From the Utilities menu, select Terminal.
At the prompt, type the following command and then press return: csrutil disable
Terminal should display a message that SIP was disabled.
From the Apple menu, select Restart.
Now you need to define an environment variable that points to the folder with libiodbc.dylib. To figure out where that folder is, type this in Terminal:
find / -name libiodbc.dylib 2>&1 | grep -v "find: "
Using your favorite text editor (like pico, emacs, or vi), you need to edit your .zshenv file. Open this file (or create it if it does not exist) with
pico ~/.zshenv
Using the first folder from above, define an environment variable by typing this in the file:
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:<FOLDER-PATH-HERE>
Save and exit the text editor.
To apply the changes to the current shell, type source .zshenv.
This should make Stata and BQ play nice again.
zsh is the default shell starting with Catalina, so if you use another shell, you should modify things accordingly. I use bash myself, but I hope my translation for zsh works.
You may need to start Stata from the command line for this to fully work.
Here's the output of the command after the fix above:
I got this to work on Apple Silicon/ Monterey. At some point Apple rolled out SIP (https://support.apple.com/en-us/HT204899) and the env variable LD_LIBRARY_PATH is no longer accessible, so STATA is unable to find the .dylib file.
Instead of disabling SIP, which is strongly discouraged by Apple, load STATA from the command line and set LD_LIBRARY_PATH in the same command.
Something like this (your paths and STATA version may vary)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/homebrew/lib/ && \
/Applications/Stata/StataIC.app/Contents/MacOS/StataIC &

Vim Vundle broken, can't open file

My vim setup apparently has broken out of nothing. It now spills errors for every single plugin I have configured. This started happening after I have changed some appearance settings, some syntastic features (both of which I don't think are the cause) and changed my shell to fish (this MAYBE is the cause).
Using the directive set shell=/usr/bin/fish or set shell=fish does not change anything, it still fails, for which I tried after reading this question.
The errors happen for both :BundleInstall and :BundleUpdate. My full vimrc file is available here if there is need to read it, it's not long.
Yes, setting your shell to fish is likely to be the root of your problem. The fish shell doesn't support the standard UNIX syntax for file redirections, which breaks Vim's system(). Just set Vim's shell to sh:
set shell=/bin/sh
You can't use the interactive features of fish from Vim anyway.
A while back I wrote up some docs for this on the Vundle wiki that you may find useful. In short, you can either:
Run: env SHELL=(which sh) vim +BundleInstall! +BundleClean +qall
Add set shell=sh to your .vimrc
As an aside, my Tackle project has an Up plugin that includes a handy way to update your vim plugins via Vundle.

"subl" command not found

When I try to edit a file, like ~/.gemrc, in the terminal, I get this error:
$ subl ~/.gemrc
-bash: subl: command not found
Follow the instructions here.
If that doesn't work and you are using RVM, run: ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/.rvm/bin/subl
Note that in both of these commands, it's assumed that Sublime Text 2 is installed in your Applications directory. If its installed elsewhere change your command accordingly.
Then, enter export EDITOR='subl -w' to enable editing with the subl command.
Do you have "Sublime Text 2" installed? It's a text editor and is what the subl command would launch.
Since you don't have Sublime, you could use vim, which is installed on Mac OS, and is a very powerful text editor, but it does have a learning curve.
There's also nano, which will do for simple text editing purposes Try entering man nano at the command-line for more information. Try entering nano ~/.gemrc to create the file in question.
It sounds like you're not really familiar with your computer or its operating system. Trying to learn to program without understanding it is going to put you at a disadvantage, because languages like Ruby, Python and Perl tend to be used for a lot of OS-level code plus web and communications, which is a "heap of learning".
I'd recommend spending some time learning about the basic commands of your command-line, and get familiar with either vim or download Sublime and try it. (And, if you use Sublime or vim regularly, encourage the author by purchasing a copy -- they're very good editors and we want to keep those sort of tools around.)

How to set my GVim to be feel like IDE?

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

Resources