Jumping to corresponding / matching Brackets in Coda Editor - coda

I'm using Coda IDE on Mac OSX.
In eclipse there's a feature called "Jump to matching bracket" (invoked by Command+Shift+P).
Is there any equivalent, or perhaps a plugin, in Coda ?

I know this is months later, but figured better to leave my findings here in case someone else winds up here, too.
I recently started using Coda 2 and have been looking to just jump to a matching bracket (in Textpad on Windows it was something like Ctrl+M).
This is the closest I've found:
For visualizing: while typing passing over a bracket will animate a circle over its matching one (you're out of luck if it's off thescreen!)
For cursor placement: at the parenthesis or bracket Command+B (or double clicking it) will select the block, you can then just hit the left or right arrow to move past or preceding the selection
For both: you can use cold folding, Ctrl+Command+left arrow to fold and right arrow to unfold
For HTML: try this plugin and use Ctrl+B: Zen.Coding-Coda.v0.7.1.zip (Github | Google Code) (don't use the new version named Emmet or something to that effect, the plugin did not work for me, this old one I'm linking to still seems to work for Coda 2 as of this writing (Coda 2.0.4))
Not as obvious as other editors/IDEs and may take some getting used to.

Related

VIM: motion without jk and HardMode installed

I am enjoying hardmode and have definitely seen improvement. However the one item I am dealing with is selecting, moving, copying only two lines at the time. Current line +1 or -1.
Before hardmode the way I would select three lines of code in visual mode would be with the motion:
V2j
Since HardMode disables the "j" key what would be a good substitute to such move?
About HardMode:
Hard Mode is a plugin which disables the arrow keys, the hjkl keys,
the page up/down keys, and a handful of other keys which allow one to
rely on character-wise navigation. The philosophy behind Hard Mode is
that you'll never master Vim's advanced motion and search
functionality if you can fall back on the anti-pattern of fumbling
around your code with the arrow keys.
https://github.com/wikitopian/hardmode
For me, HardMode is all about changing your mindset about how you move in vim. Really getting comfortable with text objects, searching etc.
In this case, you can just use 3V (3 <S-v>) to select 3 lines.
I'd urge you to learn some ex commands while you work in HardMode. Like use
:8,15d " To delete lines from line no. 8 through 15
:8,15co . "To copy range of lines 8 through 15 to current cursor position.
You can also use
:.+3 " To move down
:.-3 " To move up 3 lines
but then you'll be totally missing the point. Just use HardMode for what it's meant to be. Which is learn a few things in a constrained situation.
I think I see the point of hardmode now, and you got an answer for how to select multiple lines in visual mode. That answer is correct, but maybe you don't need to select at all? You mentioned copying, or moving, a few lines. For that, try using counts with your yank/delete commands. Example, to copy 5 lines:
5yy
To delete 3 lines:
3dd

Emacs / vim quick copy paste

I'm trying to make a transition to emacs (using evil mode/vim keybindings) and I'm having a hard time feeling more efficient/productive than if I just used the mouse. Here is an example of a situation where I find myself really slow:
for i in range(self.allData.shape[0]):
self.correctSequence = self.displayNumbers(i, self.allData)
self.userSequence = self.numberEntry()
self.allData.set_value(i, 'userSequence', ''.join(self.userSequence))
if len(self.correctSequence) != len(self.userSequence):
self.allData.set_value(i, 'correct', 0)
else:
if list(reversed(self.correctSequence)) == self.userSequence:
self.allData.set_value(i, 'correct', 1)
else:
self.allData.set_value(i, 'correct', 0)
It would be very common for me to have to change the first 4 instances of self.allData to something else (self.testData, for example), leaving the last 2 untouched.
Normally this wouldnt be too bad with a mouse. For example, I could replace the first allData with testData, copy it, use the mouse to the next 3 occurences and just hit CTRL-V for each one. Or better yet, just use multiple cursors in sublime/atom and replace all 4 in one go
I use spacesmacs in emacs with vim keybindings. So, in emacs I find myself having to do something like the following:
SPC-SPC a (avy jump to words beginning with a)
cw testData
Repeat those 2 steps once for each word I want to replace
This seems really inefficient and I'm wondering: am I just using an inefficient method? Is there a faster way to do what I want?
It seems that even if I managed to complete those steps really fast (4 times), theres still A LOT more typing one would have to do, and I fail to see how this would be faster than just reaching for the mouse. Yes, one could make the argument that I'm losing time by constantly reaching for the mouse, but in my mind I'm saving typing time by reaching for the mouse because I can just hit CTRL-V a few times to achieve what I want. Where exactly are the vim speed gains in a situation like this?
If you just want to replace, you can use query-replace, and replace the word one by one.
You can use replace-string too, but remember to limit replacement to part of the buffer, activate the region around that part.
Anyway, these commands could prevent you from finding the word by your eyes, moving cursor by mouse and moving your hand back to keybaord. And they could avoid probable overlook too. At least I don't want to leave my hands from the keyboard when typing. :)
I'm not sure how "vim-like" Spacemacs is, but you could do it like this in Vim:
/all<CR>
cgntest<Esc>
.
.
.
or:
/all<CR>
cetestData<Esc>
n.
n.
n.
or:
:,$s/allD/testD/gc<CR>
Maybe one of these methods works in Spacemacs too?
In addition to the usual (and generally the best) answer, query-replace (see #songyuanyao's answer), you can use the secondary selection to advantage to selectively paste the same thing at various places. Unlike the region, the secondary selection is unrelated to the cursor position (aka point), so it is always available regardless of where the cursor is.
And unlike query-replacing, you can paste it on demand, instead of having to answer for each matching occurrence. If you use delete-selection mode then just select some text to replace and paste the secondary selection to replace it.
You can set and paste the secondary selection using the mouse - see Secondary Selection on the Emacs Wiki, and see the Emacs manual, node Secondary Selection.
If you use library second-sel.el then you can use the secondary selection from the keyboard as well, and get a lot more use out of it.

VIm change bracket types (without using search and replace) [duplicate]

This question already has answers here:
Quickest way to change a pair of parenthesis to brackets in vim
(6 answers)
Closed 8 years ago.
I am looking for a VIM key combo for changing something like
blahblah["hello"]
to
blahblah("hello")
My best effort so far is
0f[yi[%c%()^["0P^[
but anything better would be much appreciated.
BTW, my combo works by doing:
find the first instance of [ (you get my point),
yank the insides (which of course means to register 0 by default, and it leaves the cursor on the first "),
move the cursor back onto the first instance of [ with %,
delete the whole [...] bit and go into insert mode,
write () and <Esc> out of insert mode,
paste the contents of register 0 in between the ().
I was hoping to have a muscle-memorable key combination that I could use for things like this where you want to 'keep the contents but change the surroundings'.
My proposal, if you reduce it to the minimum (and use ca[ rather than %c% -- credit to this SO for the a motion that I had not really known about) is not too bad because it is the sort of thing you can invent again once you know it is possible:
yi[ca[()<Esc>"0P
However, it occurred to me that a search-and-replace is going to be just the right kind of solution when you need to do a few of these in a file. Here is my best effort:
select the area in visual mode (I tend to use VISUAL LINE mode as a default),
then :s/\[\(.\{-}\)\]/(\1)/g<Enter> and you're done.
That itself looks a bit mad, but it is just a simple example of so-called backreferencing so I was quite happy to have had to get that clear in my mind too.

Keyboard shortcut to "Comment" a line in NANO?

I love NANO. It's always there, it can slice and dice, and its NOT VIM!
But I am constantly hitting Command / - inadvertently - as I go along, out of habit.. Most IDE's use this convention to "comment out" a line.
NANO has great syntax highlighting.. so it knows the context of my documents.. but I haven't been able to figure out a way to get it to perform this basic, yet relatively important function.. Hand-commenting is for the birds.
I suppose this is sorta a super-user question, but in my experience, this would get a bunch of blank stares and then a few people asking who Nano was, so... here it is...
Oh and PS, brownie points for anyone that knows how to get DashCode to be able to do this as well... It would be the finest Javascript IDE EVER if it could perform this trick... and I'm convinced Apple omitted the feature for just that reason, lol.
The simplest workaround I've found:
Comment-out:
set the cursor at the first row that should be commented-out
hit twice 'M-R' (or 'Alt-r'; in order to Replace a RegExp)
Search for: '^'
Replace with: '# '
Replace this instance?: 'y'
press 'y' for each row to be commented-out
Comment-in:
The same procedure, replacing '# ' by ''
New in nano 2.6
(2016 June 17)
comment/uncomment lines with default binding M-3 (Meta-3)
(http://git.savannah.gnu.org/cgit/nano.git/tree/NEWS)
Customization
If you do not like the default mapping, note following:
Using Ctrl-/ by rebinding it in ~.nanorc with bind ^/ comment main is not possible. On a linux console this is equivalent to a backspace (https://savannah.gnu.org/bugs/?53248).
Some possible alternatives could be:
Meta-; (emacs)
Alt-/ (micro)
While accepted answer is de jure correct, it doesn't really help if you're not proficient in Nano already.
Indeed since Nano 2.6 this functionality is available as M-3 (Meta-3). But what it actually means (see doc) is that comment\uncomment can be done via these hotkeys:
<Alt> + 3 // <Alt> is default <Meta> command
<Esc> + 3 // Single <Esc> should also work
And since usually you need to comment out several lines, you can use Alt + a (or Meta + a / Esc + a) to switch to selection mode which will allow to select several lines. Then comment command will be applied on all selected lines at once.
Related question: How to comment multiple lines in nano at once?

Which editors out of Emacs, Vim and JEdit support multiple simultaneous text insertion points?

Background: JEdit (and some other text editors as well) support a feature called Multiple simultaneous text insertion points. (at least that's what I'm calling it here).
To understand what this means, take a look at the link.
Out of all the features in use in modern text editors, initial research seems to indicate that this is one feature that both Emacs and Vim do not actually support. If correct, this would be pretty exceptional since it's quite difficult to find a text editor feature that has not made its way into at least one of these two old-school editors.
Question: Has anyone ever seen or implemented this feature in either Emacs, Vim, or both? If so, please point me to a link, script, reference or summary that explains the details.
If you know an alternate way to do the same (or similar) thing, please let me know.
The vim way to do this is the . command which repeats the last change. So, for instance, if I change a pointer to a reference and I have a bunch of
obj->func
that I want to change to
obj.func
then I search for obj->, do 2cw to change the obj-> to obj., then do n.n.n. until all the instances are changed.
Perhaps not a flexible as what you're talking about, but it works frequently and is very intuitive and fast when it does.
moccur-edit.el almost does what you want. All the locations matching the regexp are displayed, and the editing the matches makes changes in the corresponding source. However, the editing is done on a single instance of the occurrence.
I imagine it'd be straight forward to extend it to allow you to edit them all simultaneously (at least in the simple case).
There is a demo of it found here.
Turns out, the newest versions of moccur-edit don't apply changes in real-time - you must apply the changes. The changes are also now undoable (nice win).
In EMACS, you could/would do it with M-x find-grep and a macro. If you really insist that it be fully automatic, then you'd include the find-next in the macro.
But honestly, this strikes me as a sort of Microsoft-feature: yes, it adds to the feature list, but why bother? And would you remember it existed in six months, when you want to use it again?
For emacs, multiple-cursors does exactly that.
Have a look at emacsrocks episode 13, by the author of the module.
I don't think this feature has a direct analogue in either Emacs or Vim, which is not to say that everything achievable with this feature is not possible in some fashion with the two 'old-school' editors. And like most things Emacs and Vim, power-users would probably be able to achieve such a task exceedingly quickly, even if mere mortals like myself could spend five minutes figuring out the correct grep search and replace with appropriate back-references, for example.
YASnippet package for Emacs uses it. See 2:13 and 2:44 in the screencast.
Another slight similarity: In Emacs, the rectangle editing features provided by cua-selection-mode (or cua-mode) automatically gives you multiple insertion points down the left or right edge of the marked rectangle, so that you can type a common prefix or suffix to all of those lines.
e.g.:
M-x cua-selection-mode RET (enable the global minor mode, if you don't already use this or cua-mode)
C-RET down down down (marks a 1x3 character rectangle)
type prefix here
C-RET (unmark the rectangle to return to normal editing)
It should be something like this in vim:
%s/paint.\((.*),/\1.paint(/
Or something like that, I am really bad at "mock" regular expressions.
The idea is substitute the pattern:
/paint(object,/
with
/object.paint(/
So, yes, it is "supported"
It seemed simple to do a basic version of this in Emacs lisp. This is for when you just want two places to insert text in parallel:
(defun cjw-multi-insert (text)
"insert text at both point and mark"
(interactive "sText:")
(insert-before-markers text)
(save-excursion
(exchange-point-and-mark)
(insert-before-markers text)))
When you run it, it prompts for text and inserts it at both point (current position) and mark. You can set the mark with C-SPC. This could be easily extended for N different positions. A function like set-insert-point would record current position (stored as an Emacs marker) into a list and then when you run the multi-insert command, it just iterates through the list adding text at each.
I'm not sure about what would a simple way to handle a more general "multi-editing" feature.
Nope. This would be quite difficult to do with a primarily console-based UI.
That said, there is similar features in vim (and emacs, although I've not used it nearly as much) - search and replace, as people have said, and more similarly, column insert mode: http://pivotallabs.com/users/brian/blog/articles/350-column-edit-mode-in-vi

Resources