Guys I am using Spyder ide, but when I go to modify a certain thing in any line it selects the letter and starts typing above it and deletes the already written code rather than spacing and typing, any solution?
I would try to hit the Insert key on your keyboard first and see if it toggles between the Insert mode and the Overtype mode:
overtype mode, in which the cursor, when typing, overwrites any text that is present in the current location; and
insert mode, where the cursor inserts a character at its current position, forcing all characters past it one position further.
The insert/overtype mode toggling is not global for the computer or
even for a single application but rather local to the text input
window in which the Insert key was pressed.
Related
Sometimes I find myself wanting to replace just 2-3 long words in a program and I find it a bit painful in how I do it, just wondering if there is any Vim wizards out there that could give me a faster way of doing this:
var_wanted = {}
some_other_var = {}
def function1():
....
....
some_other_var.append(...)
....
some_other_var.append(...)
some_other_var.append(...)
....
Now lets say I want to replace some_other_var with var_wanted, now usually the way I do this is I will go to var_wanted use yiw to copy the word to register, then move to the first instance of some_other_var do viw to select the word, then do p to paste it in and replace the word. However this process is not repeatable, I can't go to the next instance of some_other_var and type . because for some reason now some_other_var is in my register as opposed to var_wanted, I do this so often that I feel like I'm losing years of my life. And yes I am aware of using search and replace :%s/some_other_var/var_watned/gc, but I feel like this instance is for so few replacements that its not worth typing that whole thing out. Please heeelp
End product wanted:
var_wanted = {}
some_other_var = {}
def function1():
....
....
var_wanted.append(...)
....
var_wanted.append(...)
var_wanted.append(...)
....
TL;DR:
Cursor on var_wanted: "ayiw (yank into register a).
Cursor on some_old_var: ciwCtrlraEsc (change word, insert contents of register a).
Put cursor on next some_old_var: . will do the previous action again.
Finding a keystroke series that's shorter than %s/some_old_var/var_wanted/g is going to be difficult.
because for some reason now some_other_var is in my register
viwp is implicitly deleting the selected word. Deleted text in vim goes into the register. You can avoid this with viw"_dP instead, which explicitly deletes into the null register so it does not get copied, and then puts. Typing this 3 times seems worse than the %s/ version.
If it's typing var_wanted and some_other_var that bothers you, you can yank them into registers (let's use "find and "replace for mnemonic purposes) via "fyiw and "ryiw when your cursor is in the right spots. Then you could just %s:<C-r>f:<C-r>r:g to do all the replaces (<C-R> means Ctrlr). The problem here is moving the cursor around and then yanking doesn't seem much faster than typing the word.
There's also changing things. If you had some_old_var., you could position your cursor on the word and then ciwvar_wanted, which would remove some_old_var and enter insert mode where you would type var_wanted. The benefit to this is after leaving insert mode, you could use . when your cursor is on the next instance of some_old_var and it would repeat the whole action, replacing some_old_var with var_wanted.
Another useful note is that if var_wanted is super long (and exists in this file already), you can use C-n to autocomplete after you've typed a few characters of the word. This would still work with . after you finished the insert.
If you really want to avoid typing any amount of var_wanted, you can use the Ctrlr in insert mode as well, meaning you can yank var_wanted by putting your cursor on it and using "ayiw (to yank into register a) and then putting your cursor on some_old_var and doing ciw<C-R>a to replace it.
As long as your desired register is the yank register:
:%s/some_other_var/\=#0/g
The above solution is good if you are trying to change a large number of occurences of the "some_other_var"
You can also use the "gn" approach, see :h gn, in my case I have:
:nnoremap c* *<c-o>cgn
copy the "var_wanted" move to the first "some_other_var" and then press:
c* ...................... triggers our mapping
<Ctrl-r>0 ................ paste the yank register
<Esc> .................... leave insert mode
. ....................... now press dot as much as you want
To learn more about the gn trick watch this amazing video:
http://vimcasts.org/episodes/operating-on-search-matches-using-gn/
Does anyone know how to make it so that Jupyter Notebook doesn't show me this prompt every time I select Heading option? I've created a jupyter_notebook_config.py file, but I didn't see an option to turn it off. I like to use headings often to break up my code and keep better documentation, but I find it annoying to constantly click OK every time.
The warning is not that headings are gone, it is that heading cells don't exist anymore. All text cells are markdown now, and you create headings by prefixing the line with a number of # symbols to indicate the heading level. When you see this dialog, it is not creating a heading cell; it is creating a markdown cell with the right number of # characters.
The way to avoid the warning is to create markdown cells and add the # characters yourself.
To not get a prompt you can just:
enter your text in the cell
hit esc to enter command mode
press 1,2,3,4,5 or 6 keys for getting a heading(1-6) respectively
simultaneously press (shift + return/enter)
I created a menu using:
fileMenu = wx.Menu()
fileMenu.Append(ID_NEW, "&New\tCtrl+N", "Creates a new file")
I can access New by clicking it on the menu or by clicking Ctrl+N.
My question is: What is the & stand for?
if I delete it everything is still working. However all guides still use it and none of them explain what is the purpose of it.
I've read also here:
http://wxpython.org/Phoenix/docs/html/MenuItem.html#MenuItem.SetItemLabel
"An accelerator key can be specified using the ampersand & character ... Optionally you can specify also an accelerator string appending a tab character \t followed by a valid key combination"
So according to this there is no need to use & if I use \t.
can someone confirm if my conclusion is correct? I just can't figure why I always see both... there has to be a reason why everyone are using it this way.
The & characters in menu titles indicate an accelerator that you can press while the menu is open to quickly access the item. This only works when the menu is open and focused. You'll see the underscored character in the item title as a mnemonic. Same applies to the top level menu entry as well, such as 'File' or 'Edit': by standard WIMP convention you can open said menu using Alt-F (if F is the accelerator for File) and then just as quickly press 'C' if there is an accelerator for C in that menu. Quick and very little known these days.
The \t means a tab in traditional context and in menu items it will make a global shortcut in your frame that you can press without the menu being active.
The shortcut letter following & will be accessible only from the menu.
The \tCtrl+N is available from the entire app, and the short-cut is displayed next to the menu item.
Motivation: I was going around assigning parameters read in from a config file to variables in a function like so:
john = my_quest
terry = my_fav_color
eric = airspeed
ni = swallow_type
...
when I realized this was going to be a lot of parameters to pass. I thus decided I'd put these parameters in a nice dictionary, grail, e.g. grail['my_quest'] so that the only thing I needed to pass to the function was grail.
Question: Is there a simple way in Sublime (or Notepad++, Spyder, Pycharm, etc.) to paste grails['variable'] around those variables in one step, instead of needing to paste the front and back seperately? (I know about multiple cursors in Sublime, that does help, but I'd love to find a "highlight-variable-and-hit-ctrl-meta-shift-\" and it's done.)
Based on examples you provided, this is a simple task solvable using standard regex find/replace.
So in Notepad++, record this macro (for recording control examine Macro menu):
Press Ctrl+H to open Find/Replace dialog
Find what: = (.*)$
Replace with: = grail['\1']
Choose Regular Expression and press Replace All
If you finish recording the macro and you choose to save it, shortcut key is requested. Assign your favorite ctrl-meta-shift-\ and you are done.
I am using PyCharm to write some python code and notice that I run into the following problem quite often:
I write a line of code like this
for item in myList:
Later, I realize that I would like the index of item as well, so I try to turn that line into this:
for i,item in enumerate(myList):
In order to turn the first line into the second, I put the cursor to the left of item and type i,. Then, I put the cursor to the left of myList and type enu; by this time, the code-completer suggests that I might want to type enumerate, which is exactly the behavior that I'm after. When I hit tab to implement the suggested enumerate, I notice that my line turns into
for i,item in enumerate:
The myList has been overwritten!
The behavior that I expect is this:
for i,item in enumerate(myList):
with the cursor immediately to the right of either the myList or the :.
Is there any way that I could make Pycharm behave according to my expectations?
Just in case it matters, my dev environment is Mac OSX 10.7.5 (Lion)
This behavior is by design when you complete using Tab. Please use Enter instead of Tab to insert the completion variant instead of overwriting.
Code completion settings dialog also has an option to insert variant by typing dot, space, etc.
This is default behaviour in PyCharm, if you press TAB while being connected to another word like so en|myList, then myList will get deleted.
What you can do is this, double-click myList, press CRTL+ALT+T, press ENTER, and then press <-. Then just type in enumerate.
If you do this regularly, then you can just make a live template that surrounds.