How can I set indent 2 in Aquamacs? - configuration

The default indentation is 4 for tabs. How can I set it to 2 in Aquamacs? I see a configuration file .emacs.d in my home directory, but it doesn't look like the right file:
" ============================================================================
" Netrw Directory Listing (netrw v140)
" /Users/lucerne/.emacs.d
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.in
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec
" ============================================================================
../
~

The customization option you are looking for might be:
Top Level / Editing / Indent / Standard Indent
That is,
Hit command comma or choose Options/Customize/Top-Level Customizations
Click on Editing, then on Indent, then on Standard Indent
Change the number to 2
Click on "Save for Future Sessions"
Have fun!

Related

Sublime code folding of comments (as in Ace)

In Cloud9 (based on the Ace editor) I can define arbitrary code folding regions within comments, for example:
// Descriptor {
function() {
// Code
}
// }
Folds to:
// Descriptor {<->}
Try it here to see what I mean.
Is there an existing way to replicate this in Sublime?
Select the block of code and Hit "Ctrl + Shift + [" to fold.
To unfold place pointer before the folded block and hit "Ctrl + Shift + ]"
here's an youtube video link: https://www.youtube.com/watch?v=80UUPMUAP-g
From http://wesbos.com/sublime-text-code-folding/
To fold a block, place your cursor anywhere within the block you want
to fold. Now you just hit the folding keys to collapse that block.
Command + Option + [
The thing you will have to remember is that Sublime Text's folding mechanism is dependent on code intention levels and not scope.
Yes, you use CMD+K+1 to fold at level 1, CMD+K+2 for level 2, etc
CMD+K+J will unfold all
CMD+OPT+[ will fold / hide the current level of indendation, CMD+OPT+] will unfold any of the yellow rectangle symbols at the end of a line
Comment folding works if content is a bit deeper. Instead of this
/*
line 1
line 2
line 3
*/
use:
/*
line 1
line 2
line 3
*/

Sublime Text 2 multiple line edit

I want to edit multiple lines and every "word" within that line. For example:
45 28 42 65
24 87 47 95
01 25 87 98
I want to select every whole number in all lines and put a "0x" before it so it would look like:
0x45 0x28 0x42 0x65
0x24 0x87 0x47 0x95
0x01 0x25 0x87 0x98
I know the Ctrl+shift+L to get cursors on each line, but how can I get the cursors in front of every number to mass edit all at once?
Highlight the lines and use:
Windows: Ctrl+Shift+L
Mac: Cmd ⌘+Shift+L
You can then move the cursor to your heart's content and edit all lines at once.
It's also called "Split into Lines" in the "Selection" menu.
Use multiple cursors and column selection.
In your case you just need to place the cursors at the beginning of each column containing the "words".
Linux and Windows
Click & drag to select column(s): Shift + RightMouseBtn
Add other column(s) to selection by click & drag: Ctrl + Shift + RightMouseBtn
Subtract column(s) from the selection: Alt + Shift + RightMouseBtn
Add individual cursors: Ctrl + LeftMouseBtn
Remove individual cursors: Alt + LeftMouseBtn
Mac
Click & drag to select column(s): Option⌥ + LeftMouseBtn
Add other column(s) to selection by click & drag: Option⌥ + LeftMouseBtn
Subtract column(s) from the selection: Cmd⌘ + Option⌥ + shift + LeftMouseBtn
Add individual cursors: Cmd⌘ + LeftMouseBtn
Remove individual cursors: Cmd⌘ + Option⌥ + shift + LeftMouseBtn
Then edit as needed. In your case, type 0, x.
You could also navigate as needed to the end or beginning of the words, select the words and surround with quotes or parenthesis, and so on.
References:
Column selection
Worked for me on OS X + Sublime build 3083:
OPTION (ALT) + select lines
I'm not sure it's possible "out of the box". And, unfortunately, I don't know an appropriate plugin either.
To solve the problem you suggested you could use regular expressions.
Cmd + F (Find)
Regexp: [^ ]+ (or \d+, or whatever you prefer)
Option + F (Find All)
Edit it
Hotkeys may vary depending on you OS and personal preferences (mine are for OS X).
I was facing the same problem on Linux,
what I did was to select all the content (ctrl-A) and then press ctrl+shift+L,
It gives you a cursor on each line and then you can add similar content to each column.
Also you can perform other operations like cut, copy and paste column wise.
PS :- If you want to select a rectangular set of data from text, you can also press shift and hold Right Mouse button and then select data in a rectangular fashion. Then press CTRL+SHIFT+L to get the cursor on each line.
Windows:
I prefer Alt+F3 to search a string and change all instances of search string at once.
http://www.sublimetext.com/docs/selection
On Windows, I prefer Ctrl + Alt + Down.
It selects the lines one by one and automatically starts the multi-line editor mode. It is a bit faster this way. If you have a lot of lines to edit then selecting the text and Ctrl + Shift + L is a better choice.
ctrl + shift + right-click
it works better that way
If you are looking to select the same word / value in multiple lines to then edit it, you can simply press "COMMAND + D" on the first entry and then keep pressing "D" to select the lines below
It's fine to manually select each number for a small set of numbers like in your example, but for larger collections you can do a regex search which will do the work for you.
Ctrl + F will open the search bar.
Regex searches are enabled by clicking the ".*" button on the far left.
Type in "\d+" to search for all occurrences of 1 or more digits. Clicking the "Find All" button will select each of these numbers separately.
Then you can use Ctrl + Shift + L to convert the selection into multiple cursors. From here you can do as you like.

Fold / Collapse the except code section in sublime text 2

Is there any plugin or shortcut to hide all except code section in sublime text 2?
I need to fold all except section at a time , Not fold one section at a time.
Thanks~
If you'll hover with the mouse over the line numbers you'll see arrows - clicking on any of them will fold/collapse the code
If you want to collapse/expand all - you can do so by going to edit->code folding and choose "fold all" or "unfold all":
In addition to the other answers it is also possible to fold based on level as well. So for example looking at the default key bindings for fold.
Searching for fold key bindings.
So for example a foldall, or folding level 1 would be to hold Ctrl followed by pressing the sequence k and then 1:
Or folding level 2 would be to hold Ctrl followed by pressing the sequence k and then 2:
Or unfolding all would be would be to hold Ctrl followed by pressing the sequence k and then 0 or in my defaults I also seem to have it bound to the letter j:
Warning.
Pressing Ctrl+k twice will remove a line or a count of lines.
But not really cause you can put them back one by one by Ctrl+u
One thing you can do is select the Except code bloc using a regular expression, for instance using except(.|\n)*?raise.* in your case. You can then select "Find all" in the search bar, then Edit->Code Folding -> Fold .
Windows shortcut : Ctrl-Shift-[
Mac shortcut: Cmd-Alt-[
All the Except bloc will then be collapsed.
I know this is an old question, but it still comes up high in search results and none of the answers quite do what the OP wanted.
select the code you don't want to be hidden
use "Selection" -> "Invert Selection" to select the code you do want to be hidden instead
use ctrl + shift + [ or Command + Option + ] to collapse the selection(s)
This will leave you with just the code you originally had selected visible.
Fold and UnFold function or class base only for MAC:
* Fold: command + K, command + 1
* UnFold: command + K, command + J

Shortcut to paste multiple lines - Sublime Text 2

I am using Windows 8 OS
I have some projects where I repeatedly add the same tags to different types of elements, but the format of how the elements are presented through code always stays the same. I'm looking for shortcuts that will help me do these tasks quickly. Is there a shortcut that lets you add the same tag for multiple lines that you specify? I know you can do (CTR + F3) To select clone tags and change all of them, but I want to add tags to elements that previously had no tag. Is there a way you can make your own shortcuts for your tags, like if I type in "li" It will automatically put in "" and all I have to do is hit enter?
Here is an example of the elements and tags I added:
<ul>
<li type="square">Extra Grip
<li type="square">Made of Titanium
<li type="square">Built in Selsoft Processor
<li type="square">Portable</ul>
<b>MBS:</b> 44 kN (10000 lbf)<br>
<b>Weight:</b> 1 lbs 13.2 oz (828 g)<br>
<b>Length:</b> 14.40" (36.6 cm)<br>
<b>Width:</b> 3.75" (9.5 cm)<br>
<b>Height:</b> 1.00" (2.5 cm)<br>
<b>Material:</b> Titanium
Ctrl+C, Ctrl+X and Ctrl+V let you copy/cut/paste lines if you don't select anything. So, Ctrl+X doesn't "delete" a line, it cuts it. To delete a line, the default shortcut is Ctrl+Shift+K :)
Highlighting a bunch of lines then hitting Cmd (Ctrl?) +Shift+L gives you multi-cursors on each line. I do that, followed by Cmd + Right arrow (End?) to get easily get a cursor at the end of a series of lines to simultaneously type something after each.
Ctrl+Shift+J expands the selection to the indentation level of the current line. So if you want to select a block of code with the same indentation it's really useful.
Alt + F3 select all occurrences of current word for multiple editing. Very useful.
A few written about in more detail: http://whiletruecode.com/post/7-handy-text-manipulation-tricks-sublime-text-2
Have you tried to make your own snippets? It may not be exactly what you are asking for, but could be another way to do it.
Try the New Snippet command in the Tools-menu and add the following and save it:
<snippet>
<content><![CDATA[
<li type="square">${1:Item} ${2:}
]]></content>
<tabTrigger>li</tabTrigger>
</snippet>
This will enter an <li>-tag in the current file if you type li and then press Tab.
You can also add a <scope> tag to limit it to HTML-files.

vim omni-complete may delete my previous selected word?

I'm writing HTML with gvim, but what annoys me is that the omni-complete always delete my previous word, even my previous selected ones.
For example, assume I'm writing the following code**('_' means the cursor, hereafter)**:
<a style="_" ></a>
After I Press ^X-^O, it pops out the hint list, and I select "color:"
<a style="color:_" >
And I Press ^X-^O again, it does pops out the proper hints("rgb(", "#"), but it deletes the previous word in the meanwhile, like this:
<a style="rgb(_" >
Can anyone give me some help? Thanks a lot. And this is my gvimrc:
set guifont=文泉驿等宽微米黑\ 14
colorscheme neverness_modified
set number
set guioptions-=T
winpos 0 0
set columns=1000
set lines=1000
set fileencodings=utf-8,gb18030
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
filetype on
filetype indent on
syntax on
set cindent
set completeopt+=longest
function Maximize_Window()
silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz
endfunction
" ========================
" TagList
" ========================
set tags+=/home/fish47/.vim/tags/STL.tags
" ========================
" TagList
" ========================
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
" ========================
" WinManager
" ========================
let g:winManagerWindowLayout='FileExplorer|TagList'
WMToggle
" ========================
" OmniCppComplete
" ========================
set nocp
filetype plugin on
let OmniCpp_SelectFirstItem=2
let OmniCpp_MayCompleteDot=1
let OmniCpp_MayCompleteArrow=1
let OmniCpp_MayCompleteScope=1
set showcmd
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
This is a bug in the htmlcomplete.vim script. You can work around this by inserting a <Space> between property and value, as romainl has pointed out.
Please submit a bug report (basically a link to this page) to the script's author, Mikolaj Machowski; his email address is in the script's header; the script is located at autoload/htmlcomplete.vim in the Vim install directory.
As the last change was from Apr-2011, there's a good chance the author is still maintaining it. Should you not get a response, please inform the vim_dev mailing list (cp. http://www.vim.org/community.php; you need to register first) about this; hopefully, someone else will pick it up.
Let csscomplete.vim to handle the html completion may be a solution to my problem. You can do that by adding "autocmd FileType html set omnifunc=csscomplete#CompleteCSS" in gvimrc.
It's a bug and a regression for a newer version of vim. This csscomplete.vim plugin was written for an earlier version and you using a newer version, there's an unexpected regression.
If you hack the plugin, you'll see the delete happens because it moves the cursor in reverse looking for the most obvious context, and that reverse cursor movement gets interpreted as an erase by your vim.
For me the bug was in these lines:
...
let compl_begin = col('.') - 2
while start >= 0 && line[start - 1] =~ '\%(\k\|-\)'
let start -= 1
endwhile
So yeh there's yer problem: the variable named start is passed back to vim through omnifunc and vim used to leave the existing text as-is, but newer versions interpret that motion as an erase.
So change the second while clause condition asserting the hyphen, and now you're off to the races. But that exposes a new problem, typing a letter and initiating omnifunc slows down as csscomplete.vim bogs down. But hey, one problem at a time huh.
It's like buying a car with the steering wheel mounted on the roof. It's like yeh that's not going to work bub. But this is Vim, if you're not in this for the low level hacking, then you're in the wrong machine shop.