How do I disable auto-indent on Kakoune? - auto-indent

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!

Related

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...

Wrapping comments with line breaks in PyCharm

I have comments that gets balloon (PEP 8: Line too long ... > 120)
I wish there was a command that will wrap the lines with few keystrokes.
Right now, even if I type Alt+Enter and press enter on Reformat file, nothing actually changes. Is there a setting or plugin I could use to accomplish the formatting easily?
Under the Edit menu, there is a Fill Paragraph option, which does what I believe you want. You can assign a key command to this in Preferences, under Appearance & Behavior -> Keymap (search for "fill").
Personally, I choose first stroke Esc, second stroke Q, because that's what I've always used in Emacs...
Firstly, reformatting won't work, not in Python at least, where whitespace is important. PyCharm's "Wrap when typing reaches right margin" option is what you're looking for. Now this will not work when you copy and paste code, but in the places where it gives you trouble, just press enter, and it will work.
To be able to auto-reformat comments (and code, for that matter) to honor a right margin after the fact, go into Project Settings under Code Style and then further under Python. Click the Wrapping and Braces tab, and check the "Ensure right margin is not exceeded" checkbox.
Now if you select a region of lines and then run the Code/Reformat Code... command, PyCharm will do its best to wrap the comments or code appropriately.
You will probably have to do some tweaking of the results to suit your stylistic taste. For example, I wish PyCharm would do aggressive filling of text in block comments, at least optionally so.
PyCharm will not reformat code such that it becomes invalid Python, so sometimes it will still leave a line longer than the margin (120 or whatever you set under Project Settings/Code Style/General).
With recent PyCharm this now is located at "Editor -> Code Style", with the checkbox named "Wrap on typing"
The Screenshot shows PyCharm version 2016.2.1 Professional.
Updated Answer:
Use "soft wraps." You can search for it in the help bar.
View > Active Editor > Use Soft Wraps
It won't work for existing text or text that's copied in, but will for any newly typed text.

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…

Intellij IdeaVim change keys

I would really like to be able to use IdeaVIM but I am unable to figure out where I can set my custom vim key mappings. For example instead of using Esc I would like to use Ctrl-C and instead of using hjkl I like to use wasd.
I have all these already set in my .vimrc but IdeaVIM failed to load them. I can copy them over manually to whatever file is needed but there is no documentation on how to do this.
As of IdeaVim 0.35 (released 2014-05-15), key mappings in ~/.ideavimrc are supported. You can put source ~/.vimrc in that file if you want to include mappings from ~/.vimrc.
Release announcement
VIM-288
(Note: This question could probably be considered a duplicate of this other StackOverflow question.)
I've done this myself, and its pretty easy in IntelliJ 11. I know that in previous versions (9, maybe?) setting up keymap values is significantly different.
In IntelliJ 11 you can do the following:
Go to Settings
Select Keymap from the left menu
Search for Exit Insert Mode on the right side and associate whatever key you want to use, such as CTRL-C
If you like to have Vim plugin installed (I find it very handy for typing) and at the same time have Ctrl+C and Ctrl+V working for copy and paste actions, do the following:
In the IntelliJ Idea, click on File > Setting. On the left pane, expand Editor and click on Vim Emulation.
Here, under the Shortcut column, find Ctrl+C and change it's Handler (under Handler column) to IDE instead of Vim.
Repeat it for Ctrl+V as well and hit Apply and Ok.
Now, you should be able to use the keyboard shortcuts for copy and paste while keeping the Vim Emulator enabled.
IntelliJ 12.1:
Go to Settings
Select Keymap from the left menu
Find Escape under the Editor Actions section and add the Ctrl-C shortcut there. ("Escape" under the "IdeaVim" section didn't work for me)
Following the same steps, but replacing "Escape" with "Exit Insert Mode" only partially worked for me. It exited insert mode correctly but ignored the following keystroke. So typing Ctrl-C,j,j would exit insert but only go up one line instead of two.

Is it possible to toggle a vim option when switching to insert mode?

I recently discovered the spell option thanks to this answer on Code Review, and I feel that the option is both really useful (while editing) and really annoying (while reading code, because of all the false positives).
I would like to somehow enable the option automatically when switching to insert mode:
set spell
and disable it automatically when switching back to normal mode:
set nospell
Adding the following commands in your .vimrc should do the trick (as long as your not using CTRL+C to leave insert mode) :
autocmd InsertEnter * setlocal spell
autocmd InsertLeave * setlocal nospell
Since this is a great trick, I have added these lines to my .vimrc !
if you want to get rid of words being highlighted, you can add them to the "good" word list by putting the cursor over them and type zg. See :help spellfor more information