Because honestly
:wq!
is just too much to type.
Please note that the question is about original Vi (say Vi which comes with FreeBSD) not Vim.
Hold down the shift key and bang on Z twice.
ZZ is (mostly) equivalent to :wq!.
If you really want a single-keystroke solution, FreeBSD comes with the source so, in a pinch, you could modify that and re-compile. It's a bit of an overkill but it'll solve your problem.
What about "ZZ"? It has slightly different semantics to ":wq!", but is also slightly shorter.
This seems to work on solaris' old version of vi:
Version SVR4.0, Solaris 2.5.0
$ vi -c "map g ZZ" test
edit: Also, this seems to work:
$ vi -c 'map g :q!^M' test
Where ^M is actually, ^V (ctl-v) then ^M (ctl-m)
Map your favourite key to the :wq! command.
e.g. put this in your .vimrc:
map <F8> :wq!<CR>
Et voilá.
Edit:
Sorry, vim only, missed that.
Does :x work on Vi? Although for your case I guess it might be :x!
If you're using gvim you can close it with ALT+F4. Two keys, but one keypress.
If you're using vi in its own xterm, ALT+F4 should close the xterm, killing vi as well.
What's wrong with the tried and true?
:x
It's not one key press, but it's much less than :wq! which is what your question appears to truly seek.
Or is this a ViM only feature? My apologies if so.
Related
I want to read user name and display it with capital letter, i made something like that.
notice:-
write('Hi whats ur name?'), nl,
read_line_to_codes(user_input,Codes1),
capitalize(Codes1,Codes2)
->
atom_codes(Name,Codes2),
write(Name).
capitalize([],[]).
capitalize([H1|T], [H2|T]):-
code_type(H2, to_upper(H1)).
I dont understand the problem it seems, like user_input is empy and without any reading executes.
Whats even stranger this one seems to work well...
notice:-
write('Hi whats ur name?'), nl,
read(Name),
write(Name).
This image describes problem well...
How exactly are you running this code to test it?
The first version of your code works fine for me in the SWI-Prolog shell:
?- notice.
Hi whats ur name?
|: isabelle
Isabelle
true.
It also works fine when started as a "standalone" program:
$ swipl -s foo.pl -q -t notice
Hi whats ur name?
|: isabelle
Isabelle
(Although you should add a newline after the output.)
I would like this vim mapping to work in ideavim.
inoremap <S-Space> <Esc>
It maps Shift Space with Esc in insert mode.
Any ideas what to put in my .ideavimrc?
You can put exactly this line into your ~/.ideavimrc and it will result in the expected mapping.
You can try it interactively as well by typing :inoremap <S-Space> <Esc>.
Edit: It's currently not possible. Vote for VIM-1026 at IdeaVim's bug tracker to get updates.
Yakuake provides a hotkey and a GUI way to rename commandline tabs/sessions.
I'd like to do the same via the command line, so I can script it and use it in an alias. (My goal is that if I use an alias which does an SSH to some server, then the tab is renamed according to this servers name...)
I tried the suggestions shown here Renaming a Konsole session from commandline after ssh so far no luck.
Since KDE4, one should use qdbus to control KDE apps (instead of deprecated and deleted DCOP).
For example, to change a title of the first session one may use:
qdbus org.kde.yakuake /Sessions/1 org.kde.konsole.Session.setTitle 1 "New title"
To explore available interfaces, methods and properties one may use qdbusviewer.
As a homework try to get a list of active sessions (before you going to change smth).
Like #fgysin pointed out, his command also works for me. BUT it needs the ` character and not " for the subcommand :
qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeSessionId
It gives :
qdbus org.kde.yakuake /yakuake/tabs org.kde.yakuake.setTabTitle `qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeSessionId` "NEW TAB TITLE";
I'm just switch to zsh and now adapting the alias in which was printing some text (in color) along with a command.
I have been trying to use the $fg array var, but there is a side effect, all the command is printed before being executed.
The same occur if i'm just testing a echo with a color code in the terminal:
echo $fg_bold[blue] "test"
]2;echo "test" test #the test is in the right color
Why the command print itself before to do what it's supposed to do ? (I precise this doesn't happen when just printing whithout any wariable command)
Have I to set a specific option to zsh, use echo with a special parameter to get ride of that?
Execute the command first (keep its output somewhere), and then issue echo. The easiest way I can think of doing that would be:
echo $fg[red] `ls`
Edit: Ok, so your trouble is some trash before the actual output of echo. You have some funny configuration that is causing you trouble.
What to do (other than inspecting your configuration):
start a shell with zsh -f (it will skip any configuration), and then re-try the echo command: autoload colors; colors; echo $fg_bold[red] foo (this should show you that the problem is in your configuration).
Most likely your configuration defines a precmd function that gets executed before every command (which is failing in some way). Try which precmd. If that is not defined, try echo $precmd_functions (precmd_functions is an array of functions that get executed before every command). Knowing which is the code being executed would help you search for it in your configuration (which I assume you just took from someone else).
If I had to guess, I'd say you are using oh-my-zsh without knowing exactly what you turned on (which is an endless source of troubles like this).
I don't replicate your issue, which I think indicates that it's either an option (that I've set), or it's a zsh version issue:
$ echo $fg_bold[red] test
test
Because I can't replicate it, I'm sure there's an option to stop it happening for you. I do not know what that option is (I'm using heavily modified oh-my-zsh, and still haven't finished learning what all the zsh options do or are).
My suggestions:
You could try using print:
$ print $fg_bold[red] test
test
The print builtin has many more options than echo (see man zshbuiltins).
You should also:
Check what version zsh you're using.
Check what options (setopt) are enabled.
Check your ~/.zshrc (and other loaded files) to see what, if any, options and functions are being run.
This question may suggest checking what TERM you're using, but reading your question it sounds like you're only seeing this behaviour (echoing of the command after entry) when you're using aliases...?
For some reason, "C-z" is mapped to suspend-or-iconify-emacs and I can't seem to get it to rebind to something less annoying. (I like using ctrl-z for undo, but doing nothing would at least be better than suspending every time I accidentally hit the key)
I've tried doing it interactively:
M-x global-set-key, then Set key C-z to command: undo.
M-x describe-key-briefly gives me C-z runs the command suspend-or-iconify-emacs
I've tried going to the scratch buffer and evaluating:
(global-set-key (kbd "C-z") 'undo) and (global-set-key "\C-z" 'undo), and it is of course in my .xemacs/init.el file.
Nothing seems to actually rebind the key.
This is happening on XEmacs 21.5, in Fundamental mode. Any ideas on how to troubleshoot this?
edit: Ok here is a hack that gets around the problem by redefining the suspend function to undo:
(defun suspend-or-iconify-emacs () (interactive) (undo))
I can't actually suspend emacs anymore, but that's actually ok with me.
Try evaluating this:
(define-key global-window-system-map [(control z)] 'undo)
(assuming that you aren't running XEmacs in tty-mode, but I guess you are not, if you want to iconify :-))
I used C-h b to find out what *-map to modify.
I have the following code in my .emacs:
(global-set-key (kbd "C-z") 'eshell)
It will start an eshell, and it works.
The C-z combination is pretty standard on Unix/Linux, if you're working in a terminal with e.g. vi, lynx or mutt and presses C-z the program will suspend and you will be back in the shell. Issuing the 'fg' command will pop the program back again. As Emacs has its own shell, I like spawning that when pressing C-z in Emacs.
You can also add the following hook, that will remap C-z in the eshell. That way pressing C-z in the eshell with get you back to the buffer you were editing.
(add-hook 'eshell-mode-hook
(lambda ()
(local-set-key (kbd "C-z") 'bury-buffer)))
Put that at the end of your .xemacs/init.el :
(global-set-key (kbd "C-z") 'undo)
Or maybe you have a misconfigured keyboard or operating system.
Do C-h k C-z to see if xemacs really receives a C-z key.
I had the same problem with C-f. I wanted it to map to isearch-forward, but instead it kept moving one character forward.
I finally solved my problem by adding
(global-unset-key [?\C-f])
(global-set-key [?\C-f] 'isearch-forward)
Apparently the issue is that C-f (and C-z) is a "real" key, that is, it's something that a terminal recognizes (it's ASCII 0x06, 0x1a for C-z), so you need the "?\" in front of "C-f".
This is the only thing I got to work.
HTH
(EDIT: I should note that I use emacs, not xemacs)