reindent shortcut in sublime text [duplicate] - sublimetext2

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Indenting code in Sublime text 2?
I'm trying to learn keyboard shortcuts in Sublime. What is the keyboard shortcut in Sublime Text 2 for reindent? According to some pages it should be TAB but that only indents, not reindents.

You can find it in Edit>>Line>>Reindent, but it does not have a shortcut by default. You can add a shortcut by going to the menu Preferences - Keybindings-User, then add there (the config file takes as a JSON format):
[
{ "keys": ["f12"], "command": "reindent"}
]
(example of using the F12 key for that functionality)

I use cmd-[ and cmd-] for indenting but I am not sure exactly what you mean by "reindent"...
Ahh, OK I get your question now, you can use the command to re-calculate and apply correct indentation to a file. For example, if you open a file that has had been programmatically altered and had whitespace stripped or tabs removed you would use the reindent command to restore correct formatting.

Related

VsCode Emmet Requires me to press Option+Esc to show up the sugession [duplicate]

This question already has answers here:
Some Emmet abbreviations in VSC not working, like '!' or using '*'
(8 answers)
Closed 8 months ago.
On HTML file, I usually press "!" and then the Emmet suggestion will appear for me to choose but after I updated VsCode 1.69, it doesn't show up anymore 1. This issue also appear when I try to use ul>li*5. I temporary press option+esc to show it like usual but I hate to do it many times.
Thanks for helping!
You need to check this option or put "emmet.triggerExpansionOnTab": true in settings.json to use the emmet abbreviation pressing TAB. I realized this ones what is not working:
!, lorem, >, and . Examples of use: ul>li, li3, ul>li*3
None of them shows the preview of the emmet, and you can't use them pressing TAB without enabling the option that I sayed above, and even checking the option you won't be able to see the previews, you'll need to know them by yourself and press the TAB even though nothing showing that it's a emmet abbreviation.
You can use CTRL + SPACE too.
Edition Windows 11 Pro Version 21H2
VSCODE Version 1.69.0

VSCode insert tab character manually

When using VSCode, most of my files are set to be indented using spaces. However I sometimes wish to insert a literal tab. When I was using vim I'd use <Ctrl>+v <Tab> but that doesn't work with VSCode.
I've been searching and searching and cannot find anything. Please help!
Quick-and-dirty solution: Find a tab somewhere else, then copy-paste.
Chances are that you already have a tab character in the file you are editing, but if not you can generate one in another application or text editor.
You can also generate a tab programmatically in a bash shell with the following command (the brackets are optional):
echo -e [\\t]
For your more immediate needs, I have inserted a tab character below...
There is a tab character between these brackets: [&#9]
Another approach is to change the tab mode temporarily, as shown here.
I'm not sure if there is a generic solution, but you can setup a keybinding for this:
{
"key": "ctrl+v tab",
"command": "type",
"args": { "text": "\t" },
"when": "editorTextFocus"
}
This keybinding will insert an tab character even when the current mode is spaces.
<Alt> <Numpad: 0 0 9>
Still works great!
Strange, Visual Studio Code gives you a clue, but you have to hunt for it.
Turn off "Editor: Detect Indentation" which is ON by default.
After which, it will not assume that a tab is 4 spaces.
Of course, all you have to do is select your spaces, and then you will see "ghost dots" in your selection. If you delete those spaces and then type tab, you will now see 1 "ghost right arrow" when you select it which means now you really have a tab character.
When working on Makefiles, I use Find/Replace using regexes.
Replace ^ (4 spaces - change as appropriate) with \t.
You can turn off editor.insertSpaces.

How to use sublime text 2 like notepad++

In Notepad ++ we can use Move to other view for copy/paste attributes easily . But How i use sublime text 2 like two windows at a time for copy/paste attributes easily ?
If I understood your question right you will find the answer by accessing sublime's menu View>Layout>... Columns

Automatically update the closing tag when open tag changes with Sublime Text 2 on Mac OS X

See the H2 tags? How can I change them all to p tags without manually going from line to line. cmd+d is not viable because of the varying lengths of the inner content.
I found something called Emmet Plugin which I installed but can't get it to work. (Followed steps and confused by docs http://docs.emmet.io/actions/go-to-pair/).
Thanks for the help.
--UPDATE--
Not using a regex. Just to clarify I want something that will automatically update the closing tag if I change the open tag.
You need “Rename Tag” action:
https://github.com/sergeche/emmet-sublime#available-actions
Alt + F3 works for me. I'm using the Emmet plugin, though.
I use Emmet and CTRL+SHIFT+' does not work for me.
I changed the key shortcut of the command.
Preferences -> Key Bindings -> User
Content:
[
{ "keys": ["ctrl+shift+;"], "command": "rename_tag" }
]
Here are some solutions which does not require any plugins.
All solutions works on sublime2, sublime3 and atom
Using Multiple Cursors (press shift-alt and down arrow)
Using Ctrl-D (if you want to restrict the update to some elements only)
Using ALT-F3 (to update all instances of h2 -> p)
PS: For those who does not have the tags in same line, of they do have then all the contents are of different number of lines method 1 will not work both other methods will still work
If you have emmet installed: Cmd+Shift+K on mac, Ctrl+Shift+ on windows
Just use regexp. They are supported by Sublime Text 2 (in the CTRL + H).

apply syntax highlighting to files with undefined extension

I'm opening .RUL files in Sublime Text which do not have any syntax highlighting, since InstallScript has a similar syntax to C/C++ I want all my .rul files to be treated as if they were .c or .cpp files and automatically have all the same highlighting applied to them. In other words: I want to have the same effect as if I renamed each .rul file to .cpp and then opened the .cpp in Sublime.
What's the easiest way to implement this in Sublime Text 2.0.2 ?
You can open the file in Sublime Text and use menu "View" → "Syntax" → "Open all with current extension as..." → (select appropriate syntax).
Also, you can click on right bottom corner of the window. This will open similar menu, where "Open all with current extension as..." is presented too.
I'm not sure if the other solutions posted above will apply to all future instances of *.rul files, OR only to the currently open file.
I found a solution that works perfectly fine for me, just edit:
...\Application Data\Sublime Text 2\Packages\C++\C.tmLanguage
<key>fileTypes</key>
<array>
<string>c</string>
<string>h</string>
<string>rul</string>
According to:
http://docs.sublimetext.info/en/sublime-text-2/reference/syntaxdefs.html
fileTypes
This is a list of file extensions (without the leading dot). When opening files of these types, Sublime Text will automatically activate this syntax definition for them. Optional.
Press Ctrl+Shift+P and type C++, highlight Set Syntax: C++ and press Enter.
Or go to View menu > Syntax > Click C++.
/Users/HOME/Library/Application Support/Sublime Text 2/Packages/C++/C++.sublime-settings
{
"extensions": ["cpp", "cc", "cxx", "c++", "h", "hpp", "hxx", "h++", "inl", "ipp", "rul"]
}
Or, create a similar file and place it in your User directory, for rul and any other additional extensions not defined in the file mentioned hereinabove:
/Users/HOME/Library/Application Support/Sublime Text 2/Packages/User/C++.sublime-settings
{
"extensions": ["rul"]
}