Insert spaces instead of TAB in Emacs viper-mode - configuration

I am long time-vim user and recently discovered that emacs has viper-mode, offering best of both worlds (at least for me). However one thing is really bothering me since I am mostly coding in python and mixing of tabs and spaces is a big deal.
When in insert mode I would like to insert viper-shift-width spaces instead of TAB when I press TAB. How can I do this? I suppose some simple lisp function/setting is the solution.
I didn't find anything in viper-mode settings that could do this.
Edit:
I have (setq-default indent-tabs-mode nil) in my .emacs but this doesn't work when I am in insert mode (in vim meaing of insert mode) in viper-mode

First, you should ensure the default value of 'indent-tabs-mode is nil, like so:
(setq-default indent-tabs-mode nil)
Then, in viper-mode, it also depends on your viper-expert-level. At level 1 or 2, TAB appears to be bound to 'self-insert-command via the mode map viper-insert-diehard-minor-mode (which is enabled when the expert level is either 1 or 2). I guess that it is trying to provide maximal vi compatibility, which means you sacrifice some Emacs features, including the use of some pretty basic customizations.
So... you can up your expert level to 3 or higher:
(setq viper-expert-level 5) ; really, why use anything less?
If you really want level 1 or 2, but want TAB to not be a self inserting command, then add this to your .viper file:
(define-key viper-insert-diehard-map (kbd "TAB") 'viper-insert-tab)
That does the trick for me, even on level 1.

indent-tabs-mode perhaps?
What happens if you set it to nil, or unset it?
After you're in viper mode try doing M-x apropos and then search for space or tab or indent.

Related

How to make VS Code's auto-complete more strict?

I love Visual Studio Code, but its Intellisense auto-complete drives me crazy and I make more typos with it than it helps. So I feel I must be using it wrong.
The problem is very hard to explain, so I have a screenshot below:
I typed in thi. I would hope/expect/want that autocomplete would only look for anything to autocomplete that contains thi in consecutive order. But it does not. Instead it looks for anything with the letters t, h, and i in them. They needn't be next to each other, nor does the thing of interest even need to start with t.
I would like to "tame" auto-complete to only find consecutive letters. Is there a way to do this? (I use Python, Javascript, and SQL for most of my work, but I'm hoping the config is cross-language.)
Ideally, I would like the auto-complete to (a) require all letters be consecutive, (b) not require the thing of interest to start with those letters, and (c) ignore upper/lower case. But by far the most important issue to me is resolving (a).
The issue you are having is a feature added in November 2017 update. There is currently no way to turn off fuzzy autocomplete, but the issue is currently open on GitHub and the setting to change this behavior will be added.
In the meantime you can tweak your autocomplete with these settings:
"editor.wordBasedSuggestions": false,
"javascript.nameSuggestions": false,
"editor.snippetSuggestions": "bottom" / inline, none
"editor.suggestSelection: "recentlyUsedByPrefix"
From official docs:
When using the last option, recentlyUsedByPrefix, VS Code remembers which item was selected for a specific prefix (partial text). For example, if you typed co and then selected console, the next time you typed co, the suggestion console would be pre-selected.
This lets you quickly map various prefixes to different suggestions,
for example:
co -> console and con -> const.
And maybe:
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
},
It doesn't solve your problem completely, but it's the closest you can get without digging through VS Code source and creating an extension.

VS 2015 Razor Autocomplete/Intellisense dropdown hides immediately after dropdown

In VS 2015, only when in Razor (.cshtml) files, roughly half of the time the autocomplete/suggestion list/intellisense doesn't work correctly (sorry, not sure the actual term... when you type an object and hit . and the list of properties and methods shows to select from)
The behavior is that when I hit ., the list popups up for a fraction of a second and then closes. It happens so fast I try to do a quick Backspace, ., Backspace, . cycle a few times to at least see the name I need, but I usually cant' get it and end up having to find the exact name elsewhere from code. Extremely irritating...
It happens sporadically with no real pattern I can find. Here's patterns that I've ruled out:
The file that's open doesn't seem to matter.
Whether or not I close/reopen the file doesn't seem to matter
Whether I navigate to another file and back doesn't seem to matter
It will work/not work multiple times on and off throughout the same file
It doesn't seem to be relevant to any particular object/property/method
I've checked all my options (there doesn't seem to be Text Editing options for Razor?), have tried clearing caches, the reloading solution/projects, restarting VS, all of which seem to still provide no pattern.
Has anyone come across this and have any ideas of where else I can look to fix it?
Example
Here's an extremely simple example... new project, very little code/files, very simple view. Where the Model. stops, I should have the usual base methods, and an 'Items' collection. It pops up for a split second then disappears... no lambdas/complex view parsing involved (this is reproducible as well):
Update: Patterns
Things I've noticed:
If I'm entering a #model ns.ns.ns.type, it rarely happens toward the "base" end of the namespaces. It's as I get further towards the type that it happens. This one is intermittent.
In some cases, it works perfectly fine, every single time. For example, I often use DevExpress tools, and have never seen the behavior on any of their extensions (so, #Html.DevExpress(). (and other similar, not necessarily DevEx models) will never cause a problem)
It happens almost all the time when I'm accessing my #Model (which is where I most want it!). I've found some cases where this is reproducible every time (see above example), but it's about 90%+
Occasionally, as I work through the object tree, one will fail while the next works (ex: #models ProjName.Web.App.Subscriptions.Models.AccountCreateVM... it might fail on Subscriptions but work fine on Models)
Occasionally, beginning to type the name within autocomplete kicks it back into gear and it starts working again. In the above example, starting to type Acc for AccountCreateVM causes it to start working again.
I haven't found the root cause, but in all cases, CTRL+SPACE works. This isn't the best, but light years better than nothing at all.
(this shortcut is not one I've used in the past, so this is likely standard behavior, but...) If you're at the dot Model. and autocomplete list disappears, CTRL+SPACE consistently brings it back up, and when it does come back, it stays! If there's only one possible autocomplete member, it'll auto-fill the member for you upon CTRL+SPACE
This happens for me all throughout VS2015 during lambda statements.
It happens when editing code "mid-document", as in, if there is anything besides a ) or } following where I'm typing. VS appears to be struggling to tell where the current statement ends & the next statement begins.
The following code will consistently fail to trigger Intellisense at the period, even when explicitly invoked.
var subset = initialSet.Where(x => x.
var result = new Whatever();
In Razor, it is very common to be editing code between existing text and using lambda statements:
<strong>#Html.DisplayFor(m => m.</strong>
This is probably why you only experience this in Razor.
The way I work around this bug is just to write the ) to close the method.
var subset = initialSet.Where(x => x.)
var result = new Whatever();
<strong>#Html.DisplayFor(m => m.)</strong>
Intellisense can then be triggered on the period.
If you're using a method that requires a minimum of more than just the lambda (like RadioButtonFor), you'll also need to put in a comma for each of the extra parameters.
<strong>#Html.RadioButtonFor(m => m.,)</strong>
If Intellisense is appearing, but immediately disappearing again, the best solution I've found so far is to just type a few letters of any known member, then using Ctrl-Left to skip back to the period, and trigger Intellisense again (Ctrl-Space or backspace-retype). This usually gets it to appear and stay. You'll have to delete the characters you typed afterwards, which can be frustrating.
Just make sure the ) does not touch the text you are editing, and the popup will stay up.
Instead of...
#Html.Partial("ManageGrid", Model.)
Use...
#Html.Partial("ManageGrid", Model. )
The intellisense seems to get confused by touching close parenthesis. Not ideal, but this was the only way I could get it to work for me consistently.
In my specific case, i was able to solve the problem by installing the latest version Microsoft ASP.NET and Web Tools.
https://marketplace.visualstudio.com/items?itemName=JacquesEloff.MicrosoftASPNETandWebTools-9689
Once I installed it, the problem was gone. It is likely that this update fixed something that could be fixed with an older version, but either way I'm happy.
(I found this in Visual Studio under Tools->Extensions and Updates...->Updates->Visual Studio Gallery)
I had the same error and I fixed it by deleting all the files of the component model cache.
This is the path:
Users\YourName\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
Hope that helps
I use ctrl+j as a temporary solution when I know the content.
Or keep writing without right parenthesis can use the completion:
#Html.LabelFor(m => m.Name
Whenever this annoying thing happens to me, I just put an extra dot and then it works. I have to put the extra dot every time. For example, if I write this and intellisence flashes and disappears:
#Html.TextBoxFor(m => m.
then I just do this:
#Html.TextBoxFor(m => m..
And intellisense will now show after first dot. I have made this a habit until MS has a fix for it.
Instead of...
#Html.Partial("ManageGrid", Model.)
Use...
#Html.Partial("ManageGrid", Model.

Is there a way to remove search result from the find tab in PhpStorm?

In PhpStorm 9.0.2 (I do not know about the newer versions, but I am afraid it will be the same) when you search for something and get the results in the Find tab, you can mark certain results as irrelevat by selecting them and pressing the del key and this will strike them out.
When you search for something very common, which can have 5000+ occurences, even by striking some results out, the Find tab becomes very bloated.
Is there a way to completely remove a result from the Find tab, instead of just striking it out?
When using Find/Replace in Path functionality and you know that you will get a lot of results it's better to limit your search scope by either specific path, specific file extensions or some custom scope (using Scopes functionality).
If such "limiting" cannot not help (e.g. you really need to go trough each occurrence) then use Alt + Delete (the Remove action).
Please note that this action is most likely available since PhpStorm v10 only (it was added only recently).
You can check if you have it and what the shortcut is via content menu:
You can use this keymap shortcut : ALT + SUPPR (this remove the result out of the find tab)
instead of
keymap shortcut : SUPPR (this JUST exclude the result of the find tab with underline this not remove)
EDIT :
This is the exact response for your issue. Look at this screenshoot which say all :)

How can I disable shift+enter in Dreamweaver

So I'm curious how to disable the 'code-view' 'shift+enter' 'line break' shortcut in Dreamweaver. All I can find on the internet is 'why would you want to do that?' - so I can tell you ahead of time that won't be helpful to me in any way.
To answer the question however, because I know the first thing to run through everyone's head is 'why Does he want to do that' is a simple one; So I can parenthesis+linebreak+openbracket. If you follow the keystrokes, you'll note that if I hold shift across the whole thing ( which is required for the first and last ) - that I will end up with 's all over the place. This is becoming quite the annoyance and everyone on the internet has useless responses.
Thanks in advance.
As noted by #Carson Myers in the comments following my question:
To remove the Shift+Enter Keyboard Shortcut in Dreamweaver that inserts an HTML Line Feed, follow these steps:
In Dreamweaver;
Edit > Keyboard Shortcuts...
From the edit screen;
Click the 'Duplicate Set' button, and name your new set something relative to your reasoning for making the change, I went with 'Dreamweaver PHP Development', as it was in this environment that I encountered the necessity to make this change.
In your newly generated keyboard shortcut set, find the shortcut for a Linebreak in the following sub-'folder':
Insert > HTML > Special Characters > Linebreak
Once you have located this 'key', remove the 'Shift+Enter' shortcut from its list of shortcuts, and add another one if you feel the necessity.
Following these steps removes the automatic insertion of an HTML Linebreak when using Shift+Enter. In my scenario, this allowed me to type the following sequence; '()\n{\n}' without having to release the shift button.
Thanks to #Carson Myers for the information.

How do I configure Emacs html-mode to behave like TextMate's default HTML bundle?

A friend of mine is considering switching to Emacs from TextMate. He is used to TextMate's default HTML editing mode which has 4-space tab stops and inserts tab characters (i.e. it does no auto-indenting by default). It also allows completion of open HTML tags with "Cmd-Shift->". Any ideas?
I think these settings should do the trick:
(defun my-html-mode-hook ()
(setq tab-width 4)
(setq indent-tabs-mode t)
(define-key html-mode-map (kbd "<tab>") 'my-insert-tab)
(define-key html-mode-map (kbd "C->") 'sgml-close-tag))
(defun my-insert-tab (&optional arg)
(interactive "P")
(insert-tab arg))
(add-hook 'html-mode-hook 'my-html-mode-hook)
An explanation of the settings in 'my-html-mode-hook is as follows:
set the tab width to 4
force tabs to be inserted (as opposed to spaces)
force the TAB key to insert a tab (by default it is bound to do indentation, not just insertion of tabs
'sgml-close-tag is the command that inserts a close tag for you, and this setting gets you the keybinding you want
I'm having a bit of a brain freeze and couldn't figure out the simple way to have the TAB key insert a TAB character, so I wrote my own. I don't know why a binding to 'self-insert-command didn't work (that's what normal keys are bound to).
The last line just adds the setup function to the 'html-mode-hook. The key bindings really only need to be run once (as opposed to every time html-mode is enabled), but this is a little easier to read than using 'eval-after-load. It's use is left as an exercise to the reader.
I don't know about emacs's HTML modes specifically, but I can answer about general editing:
by default, Emacs doesn't autoindent, so nothing to do here.
Emacs preserves tab characters, unless you explicitely ask them changed (check out tabify and untabify). Their width is determined by the buffer-local tab-width variable. M-x set-variable, (setq...), customize at will.
you should be able to get the behavior you want with the tab key by setting indent-line-function to tab-to-tab-stop, setting tab-stop-list to (4 8 12 16...) and indent-tabs-mode to t.
Setting indent-tabs-mode allows Emacs to insert tab characters when indenting. The tab-to-tab-stop is a form of indentation that only goes to specific positions in the line, which we set to match the expected behavior of the tab characters by setting tab-stop-list to the multiples of 4.
About completion, the only thing my muscle memory tells me is "C-c C-e", but I don't remember for sure which major mode it's supposed to go with. The closest I see in the list is sgml-close-tag, bound to C-c /
A bit of politics: don't use tab characters, especially if you use widths not equal to 8. It only results in unpredictable results