set vi-style line editing interface in TCSH/CSH similar to "set -o vi" in bash - linux

in bash we can set vi-style line editing interface using set -o vi.
How to set the same in c-shell (tcsh or csh).
I tried set -o vi. but it throws error.
$>set -o vi
set: Variable name must begin with a letter.

Try bindkey -v
See this website

Related

Vim, custom tab and vertical split organization on open

Say the files in my working directory are src/example.c src/second.c src/third.c include/example.h include/second.h include/third.h.
I want to open vim in a way that automatically opens three tabs (example, second and third), where each tab contains a vertical split screen between a .c and corresponding .h file. Like the following commands would.
:tabnew include/example.h | vs src/example.c
:tabnew include/second.h | vs src/second.c
:tabnew include/third.h | vs src/third.c
Is there a way I can make a special script that will do this when I open vim?
It is safe to assume files will have the same name.
Ideally, this would happen from a shell script rather than modifying my .vimrc, if that is possible.
well if you want to do that, you clearly need a way to execute vim commands from your shell. Lets see if the vim application supplies that, by using the help command which we should ask first for every shell command:
?> vim --help | grep cmd
--cmd <cmd> Execute <cmd> before any config
+<cmd>, -c <cmd> Execute <cmd> after config and first file
So all that is needed is to chain these commands:
vim -c 'tabnew include/example.h' -c 'vs src/example.c' -c 'tabnew include/second.h' -c 'vs src/second.c' -c 'tabnew include/third.h' -c 'vs src/third.c'
as #Enlico pointed out in the comment, you should use edit or e instead of tabnew in the first command, else you will get 4 tabs. But I used your commands so you can see how easily you would have been able to solve this by reading the --help output.

configuration of tty on BSD system

For a command like this one on Linux debian-linux 4.19.0-1-amd64 #1 SMP Debian 4.19.12-1 (2018-12-22) x86_64 GNU/Linux with xfce I get :
alain#debian-linux:~$ dbus-send --system --type=method_call --print-reply --dest
=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatable
Names
The same command on OpenBSD LeOpenBSD 6.4 GENERIC.MP#364 amd64 with xfce I get :
ktop/DBus org.freedesktop.DBus.ListActivatableNames <
On linux, at the end of screen, we go to next line.
On BSD(OpenBSD-NetBSD), the command line continue on the same line and the first words disapear.
It's the same in xfce-terminal-emulator, xterm or in TTY (Alt-Ctrl-F3)
I try to add am in gettytab in the defaut section with no avail.
Termcap man page say :
If the display wraps around to the beginning of the next line when the cursor reaches the right margin, then it should have the am capability.
What can I do ?
Short answer
If you want to your current shell without this feature
set +o emacs
If you want to spawn a new shell without this feature
ksh +o emacs
Long answer
This behavior is mainly due to the shell input interactive editing mode supported on OpenBSD.
In these editing modes, if a line is longer than the screen width (see the COLUMNS parameter), a ‘>’, ‘+’, or ‘<’ character is displayed in the last column indicating that there are more characters after, before and after, or before the current position, respectively. The line is scrolled horizontally as necessary.
If you want to remove this feature, you can use set build-in command present in sh or ksh. You can also remove this flag during invocation by using +o
Finally, if you want to check if some interactive editing modes are enabled on your current shell, you can invoke set -o or set +o without argument. It will give you something like that, here the set -o command:
$ set -o
Current option settings
allexport off keyword off notify off verbose off
braceexpand on login on nounset off vi off
bgnice off markdirs off physical off viraw off
csh-history off monitor on posix off vi-show8 off
emacs off noclobber off privileged off vi-tabcomplete on
errexit off noexec off restricted off vi-esccomplete off
gmacs off noglob off sh off xtrace off
ignoreeof off nohup on stdin on
interactive on nolog off trackall off
and here the set +o command:
$ set +o
set +o allexport -o braceexpand +o bgnice +o csh-history +o emacs +o errexit
+o gmacs +o ignoreeof -o interactive +o keyword -o login +o markdirs -o monitor
+o noclobber +o noexec +o noglob -o nohup +o nolog +o notify +o nounset
+o physical +o posix +o privileged +o restricted +o sh -o stdin +o trackall
+o verbose +o vi +o viraw +o vi-show8 -o vi-tabcomplete +o vi-esccomplete
+o xtrace
I think what you're actually describing may be a difference between the two very different shells used on Linux and most BSDs and their very different command-line editing implementations.
This probably has nothing to do with differences between various terminal emulator implementations; nor with differences between terminal capabilities databases describing those terminal emulations.
On the BSD system(s) the default shell's command-line editor scrolls the whole like across the width of the screen depending on the position of the cursor. On some Linux systems I've seen the default shell's command-line editor wrap long lines around to continue on the next line.

Vi: "$s/$/done/" is "not an editor command"?

I am writing an infinite loop in bash:
while :
do
(whatever)
done
However, when I try to insert the "done" line in this way
vi -c "$s/$/\rdone\r/g" -c "w!" -c "q!"
What I get is that "$s/$/\rdone\r/g" is not an editor command. However, this works fine while I'm on gvim.
Does anybody has any idea why this is happening? Am I doing anything wrong?
Just replace double quotes by single ones:
vim yourfile -c '$s/$/\rdone\r' -c 'wq!'
Double quotes are parsed by bash first, and it's especially a problem with the $ signs.
vi is an ancient tool. I don't have a copy of it, so I can't test your command in vi, but your command works fine for me if I use vim. Try doing this instead:
vim file -c "$s/$/\rdone\r/g" -c "w!" -c "q!"
Also, as a side note, the w and q commands can be combined for
vim file -c "$s/$/\rdone\r/g" -c "wq!"
and the globals flag (/g) is unneeded since $ can only match once on the line.
vim file -c "$s/$/\rdone\r" -c "wq!"
That should be a little bit more efficient.

runtime! variable in less.sh

Using the vim pager that comes with the program. I am trying to re-map my less.sh to run from my home directory and call the config from ~/bin. I'm getting the error:
Error detected while processing command line: E33: No previous substitute regular expression
I think my problem is I do not understand the "runtime!" can someone explain what the "runtime!" is being used for?
This is the original lines of code from /usr/share/vim/vim72/macros/less.sh:
if test -t 1; then
if test $# = 0; then
vim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' -
else
vim --cmd 'let no_plugin_maps = 1' -c 'runtime! macros/less.vim' "$#"
This is what I trying to do placing the less.sh in ~/bin/less.sh:
if test -t 1; then
if test $# = 0; then
vim --cmd 'let no_plugin_maps = 1' -c '~/bin/less.vim' -
else
vim --cmd 'let no_plugin_maps = 1' -c '~/bin/less.vim' "$#"
fi
I am running the command by editing my .bashrc alias vless="~/bin/less.sh"
Vim's :runtime command reads and interprets Vim commands from a file that is based on one of the directories in the 'runtimepath' option. Since most Vimscript files either ship with Vim itself or are installed in the user's ~/.vim/ directory, that's a convenient way to invoke a script.
The command is a specialization of :source {filespec}, which is what you need to use; a filespec itself isn't a valid Vim command, and Vim tries to interpret it as a pattern, and stumbles across the ~ character.
vim --cmd 'let no_plugin_maps = 1' -c 'source ~/bin/less.vim' -
There's even a shortcut -S command-line option for that:
vim --cmd 'let no_plugin_maps = 1' -S '~/bin/less.vim' -

Autoindent a .lisp file from the command line and use slimv to do the indenting

I am trying to autoindent a .lisp file from the command line, leveraging vim+slimv to do the indenting.
I tried scripting it:
vi -c 'call SlimvConnectSwank()' -c 'normal gg=G' -c 'wq' -c 'q!' temp.lisp
But the swank server isn't queried to do the indenting, so this just indents the file to .lisp vim defaults (if slimv and the server were not running).
Do I need to put some sort of delay/wait -c command after the call to connect to the swank server? It seems that the whole vi process is closing much too fast, and it isn't giving swank a chance to connect. If the swank connection happens on a separate thread, I suppose this could be the case.
Thoughts/comments/suggestions are appreciated.
Thanks!
Tamas got it. It was (and I checked on this, both are actually needed; really :) ) a sleep command and swank command that got it to work.
I added this to my .bashrc and aliased it to 'ai' so that I can easily indent a .lisp file from the command line:
alias ai="vi \
-c 'call SlimvConnectSwank()' \
-c 'sleep 1' \
-c 'call SlimvEval(['0'])' \
-c 'normal gg=G' \
-c 'wq' \
-c 'q!'"
Now 'ai temp.lisp' auto indents temp.lisp to slimv+vim+swank etc. standards.
All sorts of ways to script this for auto indenting a repo of lisp files, once you have the bash command to do it for one file.
The whole process is single threaded, so no need to add delays, each command shall finish before the next one is executed. You can verify that Slimv's indenting is in charge via this command:
vi -c "call SlimvConnectSwank()" -c "setlocal indentexpr?" temp.lisp
It should print indentexpr=SlimvIndent(v:lnum).
I suspect that you have some definitions in your temp.lisp that affect indentation. First those definitions must be told to the swank server, otherwise the swank server does not know e.g. the function arguments, etc. Remember: the whole process is dynamic, the runtime information is used for indenting forms.
So I think first you need to eval the whole buffer and do the indentation only after that. You can use this command:
vi -c "call SlimvConnectSwank()" -c "call SlimvEvalBuffer()" -c "normal gg=G" -c "wq" -c "q!" temp.lisp

Resources