How to alias 'clear' to CTRL+L keystroke - alias

I have a habit of issuing the clear command.
When I run cygwin, the package containing clear isn't installed and I don't have the option of installing it. Ctrl+L is a good substitute; however, I still issue the clear command habitually.
I'd like to alias the clear keyword to issue the Ctrl+L keystroke. Is this possible to achieve in the .bashrc file, or something of the like?
Thanks!

clear clears the screen simply by outputting some ANSI escapes sequences. You can do the same thing with printf:
alias clear='printf "\e[H\e[2J"'

Related

How to stop IntelliJ from placing semicolons after an auto-completion?

so this is annoying me because I use tab to leave brackets etc and when I use auto-complete and a semicolon is being placed after the bracket this happens:
https://streamable.com/i9as2
as you can see in the first statement I'm having problems "jumping" over the semicolon while when I dont use the auto-completion in the second statement (and don't get the semicolon automatically) it's way easier to navigate through it with tab. I know that there is the shift-enter shortcut but I don't really want to develop a habbit of using it so often because I can imagine trying to do that when working with my other IDE's can become quite annoying. I searched through the options but did not find any option do disable that behavior. Does anyone know a way to get around this?
Second Tab press should jump after the semicolon, I've created a feature request for that.
It's already fixed and the fix will be available starting from 2019.2 IDE version.

How do I disable auto-indent on Kakoune?

I don't like text editors that perform auto-indentation in my code, because of various reasons, but Kakoune seems to be hardcoded to do that? Is it possible to disable it?
I couldn't find any defined "hooks" for indent, just for autocomplete.
Just run :set global disabled_hooks .*-indent in your Kakoune window or put
set global disabled_hooks .*-indent
in your kakrc.
Found the answer at https://github.com/mawww/kakoune/wiki/How-To#disable-auto-indentation, although it wasn't immediately clear what "disabled_hooks option" meant.
It's not strictly an answer to your question, but I sometimes need to paste text into kakoune over an SSH session from Windows. In vim, I could do :set paste/:set nopaste.
In kakoune, I found I can enter insert mode with disabled hooks (see "Disabling Hooks" in https://discuss.kakoune.com/t/hooks/544) by typing in a \ first, e.g. \i. Then I paste the text without indentation fuss and can leave insert mode again. Neat!

QtCreator CMake editor indenting

I have my Qt Creator 3.1.1 setup to indent with 4 spaces on Tab, but for some reason tab key doesn't work when I edit CMakeLists.txt. This only happens when I open it with CMake Editor, it works when I use Plain Text Editor. Is this a bug or I need to configure it somehow to make Tab key work?
I had exactly the same problem.
This issue occured because I have enabled auto-indent. The value in the "Preferences->Text Editor->Behavior" tab "Typing->Tab key performs auto-indent" was set to something else to "Never".
So to fix this issue you you need to set "Tab key performs auto-indent" to "Never".
Additionally to the answer above, inside 'Options' window and 'Behavior' pane, have a look at 'Tab Policy' section as well as 'Cleanups upon Saving' - and check if it is really what you expect.
For me the settings there were not what I have expected and it was triggering issues, eg. in a Makefile, first command of a task looks like line continuation for Qt Creator so, upon saving, it was "cleaning" (= breaking) the indentation by replacing it with 4 spaces, that was incoherent with overall indentation in the script. Et voilà - error, make didn't work correctly!
As always, it is a very nice tool but one needs to know how to use it...

Disable use of MacVim keyboard shortcuts

Is there any way to disable keyboard shortcuts in MacVim? I mean the shortcuts like Cmd + s for example, I want to convince myself to use things like :w, but I can't do so if I can save the file using Cmd + s, you get me?
But I of course, still want to use the GUI, so is there any way to disable these, without stoping using the MacVim GUI?
Thanks for your help. BTW I made a Google search and wasn't able to find an answer.
EDIT:
Following #ChrisJohnsen's suggestion, I have already tried the following with no success:
if has('gui_running')
macmenu File.Save key=<nop>
macmenu File.Save\ As\.\.\. key=<nop>
endif
EDIT 2:
I moved the error I'm getting over to this other question: When I try to run vim in command line I get Python errors
There is no simple way to disable all of the pre-defined Mac-style keyboard shortcuts, but you can definitely change/disable any of them. The important command is :macmenu (see :help :macmenu); it lets you set the Mac-specific properties of any Vim menu item (mostly Mac-specific keyboard shortcuts and Mac-specific actions (e.g. open/save dialog boxes, window manipulations, etc.)).
macmenu File.Save key=<nop>
macmenu File.Save\ All key=<nop>
macmenu File.Save\ As\.\.\. key=<nop>
The thing is that :macmenu commands are only effective if they are in your .gvimrc file.
If you do :e $VIMRUNTIME/menu.vim and search for macm, you will find the list of pre-defined shortcuts and actions. Copy the desired lines to you .gvimrc and replace key=<whatever> with key=<nop>. You can also wrap them in if has("gui_macvim") / endif if you need your .gvimrc to work on multiple platforms.
MacVim has only one "advantage" over plain Vim: it supports native Mac OS X shortcuts. If you don't want those shortcuts you might as well simply use plain Vim.
FWIW, when I switched from TextMate I, too, found after a while that these native shortcuts were an obstacle on my way to learning Vim. My solution was to focus my efforts on plain Vim. After a week in the terminal you should be able to completely disregard those shortcuts.
I'd advise you to take a little pause and think about doing things in a more appropriate order:
In the terminal, do $ vimtutor as many times as needed.
In the terminal again, use $ vim for simple tasks first then more complex tasks. There's a predictable productivity hit at the beginning but it will last only a few days/weeks.
Once you have reached your previous level of productivity, you can start to fly Vim full-time. At that point, using MacVim or GVim or plain $ vim should make no difference whatsoever.
Bonus points for not relying too much on plugins, other people's vimrcs or "distributions" like janus or spf13…

MacVim :e expands to Edit, and Edit! won't let me discard changes?

When I type :e, MacVim automatically expands this to :Edit. The problem with this is that I can't discard my current buffer with :Edit!, because I get an error message saying that "!" isn't allowed.
I have two questions:
Why does :edit! work and not :Edit!
Is there a way to disable this auto-expand feature in MacVim, or perhaps switch it to expand to :edit! and not :Edit! ?
Thanks!
If the expansion happens immediately after typing the e, it might be due to a command-mode mapping (i.e. :map!, :cmap or :lmap). If it is only expanded after typing e followed by a space (or enter), then it might be an abbreviation (i.e. :abbreviate or :cabbrev).
You can temporarily avoid a mapping-based expansion by typing Control‑V or Control‑Q before e. Another workaround is to type Control‑F while entering a command-line command (i.e. you are at the : prompt; or type q: instead of : when starting a command). This will bring up the command-line window so that you can edit your command via normal/insert modes (this avoids all command-line mode mappings).
Once you have a way to enter e into a command-line again, you can use :verbose to find the source of the mapping:
:verbose cmap e
(You must either use the command-line window to type this literally, or enter it at the command-line by typing a Control‑V or Control‑Q before each e.)
This will show you the definition of the mapping. Additionally, if it came from a plugin, then the source will be identified with a second line like Last set from /path/to/some/file.
Checking for an abbreviation is a bit tricker since there are two chances for expansion (while typing and when the command line is being parsed):
:verbose cab ^Ve
The ^V needs to be an actual Control‑V. Usually you accomplish this by typing Control‑V twice (or Control‑Q, then Control‑V).
As for the Edit command itself, it is not a built-in command, so something plugin must be defining it. Very few built-in commands start with an uppercase letter, and all “user defined” commands must start with one; see :help E183.
You can use :verbose again to find where :Edit was defined:
:verbose command Edit
I suspect the mapping/abbreviation and the command probably come from the same place.
You can manually disable a mapping-based expansion with :cunmap and an abbreviation-based expansion with :cunabbrev:
:cunmap e
:cunabbrev ^Ve
Again, you may need type Control‑V or Control‑Q before each e, and the ^V must be a literal Control‑V (type Control‑V twice to enter it).
Unfortunately, you can not just put these in your ~/.vimrc if the definitions are coming from a plugin because plugins are loaded after ~/.vimrc. You should investigate the plugin to see if it offers a option to disable the intrusive mapping. Sometimes plugins check a :let variable to see if they should enable some feature. Maybe your problematic plugin has a “knob” that will let you tell it not to install its e -> Edit expansion. If not, you might be able to report a bug about :Edit! not working properly and ask for a way to disable the expansion too.
Do you use TextExpander, Typinator or some text expansion utility? If yes, those might be the culprit. As far as I know, MacVim does not expand text like that.