How to comment a block of statements in Inno Setup? - comments

I am using Inno Setup 5 (Unicode).
How can a block of statements be commented/uncommented using keyboard shortcut keys?

To comment blocks of code (under the [Code] section) use:
{ commented code } or
(* this is comment *)
The Inno Setup Compiler IDE does not support shortcut keys for inserting comments.

The correct comment character is a semicolon - like this:
; This is a note
You can use other methods - however, they will show as underlined in red. But a semicolon with nothing to the left of it (except white space) will turn the line green.
So if you have a line like this:
Source: distrib_v2.9\vcredist_x86.exe; DestDir: {sys}; Flags: ignoreversion 32bit;
and you put a semicolon in front of that line like this:
;Source: distrib_v2.9\vcredist_x86.exe; DestDir: {sys}; Flags: ignoreversion 32bit;
Then the entire line turns green as a comment.
There is no shortcut key that I know of. Since it is only one character, I don't think a shortcut key is needed.
Note that the left and right curly brackets {} are used for constants in Inno Setup. I do not recommend that you use them for comments. An example is {app} or {sys}. These are not treated as comments.

Related

Wrong coloring of commands after comment line in ST2

Syntax coloring is very useful, but I have problems with it in Sublime Text 2. In particular, when a line beginning with a command (like ALLOCATE in Fortran) is after one or more commented line, the command changes the color as if it is a variable.
ALLOCATE(XYZ%CC(3,NC(1),NC(2),NC(3)))
!ALLOCATE(XYZ%CV(3,NF(1),NF(2),NF(3)))
ALLOCATE(XYZ%CV(3,NC(1)+1,NC(2)+1,NC(3)+1))
This can be corrected by replacing Packages/Fortran/Syntaxes/Fortran - Modern.tmLanguage with this version. To use, save the raw version of the file in the gist as Fortran - Modern.tmLanguage. Next, in Sublime, select Preferences → Browse Packages… to open the Packages folder in your operating system's file manager. Open the Fortran/Syntaxes folder and replace the existing Fortran - Modern.tmLanguage file with the new one. Also, make sure you delete Fortran - Modern.tmLanguage.cache, otherwise the changes won't take effect.
Then end result is now:
in contrast with the original behavior:
Why the change was needed, and how it works
I used PackageDev to translate the XML-based .tmLanguage file into a much more readable YAML-based format. In it, there were two sections defining comments, one for comment blocks starting with !-:
- begin: (^[ \t]+)?(?=!-)
beginCaptures:
'1': {name: punctuation.whitespace.comment.leading.ruby}
end: (?!\G)
patterns:
- name: comment.line.exclamation.mark.fortran.modern
begin: '!-'
beginCaptures:
'0': {name: punctuation.definition.comment.fortran}
end: \n
patterns:
- match: \\\s*\n
and one for comments just beginning with !:
- begin: (^[ \t]+)?(?=!)
beginCaptures:
'1': {name: punctuation.whitespace.comment.leading.ruby}
end: (?!\G)
patterns:
- name: comment.line.exclamation.fortran.modern
begin: '!'
beginCaptures:
'0': {name: punctuation.definition.comment.fortran}
end: \n
patterns:
- match: \\\s*\n
This additional complexity is unnecessary and confusing, and not even the right way of doing it. There is no need for a punctuation.whitespace.comment.leading scope (and where did that .ruby suffix come from?), and the regexes for the actual comment block were overly complex and incorrect.
I removed both of the above sections and replaced them with this simple section:
- name: comment.line.exclamation.fortran.modern
match: (!-?).*$\n?
captures:
'1': {name: punctuation.definition.comment.fortran}
The regex is quite straightforward: capture the first group in parentheses - a ! optionally followed by a -, and scope it as the comment symbol. Then, match anything up to the end of the line ($), optionally terminated by a newline character. I'm not even completely sure of how the previous regexes worked...

How would you do a cut and paste with this in VIM?

Say you had this text:
SOMETHING_XXXXXXXXXXXXXX_ELSE
SOMETHING_XXXXXXXXXXXXXX_ELSE2
SOMETHING_XXXXXXXXXXXXXX_ELSE3
SOMETHING_XXXXXXXXXXXXXX_ELSE4
And you wanted to replace all XXX..XXX with this word:
HELLOWORLD
If I go into visual mode, then yank the word, how could I then replace the XXX..XXX in the 4 lines above using cut and paste?
If I try, what happens is the X gets into my 'clipboard' and then I'm stuck to just typing it out manually.
I'm not sure if it will work in viemu, but in VIM you can do the following...
Using Yank and Paste
Yank the text to a specific register. Select the text in visual mode and use the command "ay to yank the text to the register a. Then when pasting call the command "ap, which pastes the contents of the a register.
Using Normal Command
But I would strongly prefer to use the normal command. Just select the lines
SOMETHING_XXXXXXXXXXXXXX_ELSE
SOMETHING_XXXXXXXXXXXXXX_ELSE2
SOMETHING_XXXXXXXXXXXXXX_ELSE3
SOMETHING_XXXXXXXXXXXXXX_ELSE4
using line visual mode (<C-v>) and then issue this command: :'<,'>normal fXct_HELLOWORLD. Then you'll have
SOMETHING_HELLOWORLD_ELSE
SOMETHING_HELLOWORLD_ELSE2
SOMETHING_HELLOWORLD_ELSE3
SOMETHING_HELLOWORLD_ELSE4
This means that it will run the command fXct_HELLOWORLD for each line. Let me explain the command:
fX - moves the cursor until the first X;
ct_ - deletes everything untill _ and puts you in insert mode;
HELLOWORLD - the word which will substitute XXXXXXXXXXXXXX;
One way would be to visually select all the code you want to replace and change it at once
Ctrl+v 3jt_cHELLOWORLD[Esc]
Note: it takes a couple of seconds for all lines to be updated
Another way to be by creating a macro:
record macro:
q10fXct_HELLOWORLD[esc]q
run macro on other lines:
j#1j#1j#1
q1 records a macro on character 1
#1 replays macro
But search and replace is a good alternative for your question
Highlight the four lines in visual mode, then
:'<,'>s/X\+/HELLOWORLD/g
Via this question: How do I use vim registers? I found ^R in command mode will paste from a register.
For example, with XXXX highlighted then yanked into the " register:
:s/^R"/HELLOWORLD/g

Remove default code snippets in XCode 4

I want to delete some of the default code snippets in XCode 4 because I want the beginning curly brace to start on a new line. I tried the following but XCode 4 does not seem to adhere to the rule.
defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict BlockSeparator "\\n"
Any suggestions?
Thanks.
The following has worked with my XCode 4 installation:
defaults write com.apple.Xcode XCCodeSenseFormattingOptions '{ "BlockSeparator" = "\n" ; }'
The "defaults write" commands have not worked for me. I got around this by adding a new code snippet with the beginning curly brace on a new line. The next time I typed 'if' I got the built-in completion but since selecting my completion from the drop-down, I now always get my completion.
See more on code snippets here: http://developer.apple.com/library/mac/#documentation/IDEs/Conceptual/Xcode4TransitionGuide/Orientation/Orientation.html#//apple_ref/doc/uid/TP40009984-CH5-SW1
Edit:
And a bit more here:
http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Editing/Editing.html#//apple_ref/doc/uid/TP40010215-CH8-SW2
But not very in-depth, the only way I can see to include a replaceable piece of text (e.g. 'conditions' in the 'if' snippet) is by copying from a snippet in the code editor.

Gvim Syntax Customization

How can I make Gvim to treat(syntax highlighting) lines starting with # and ; in an assembly file as comment ? Meaning in addition to ; (which is normally the way to represent comment in assembly)
If the file is being recognised as Assembler, it will have it; $VIMRUNTIME/syntax/asm.vim has the line syn match asmComment "[#;!|].*" contains=asmTodo which matches # lines as comments.
Going by the contents of Vim 7.3's $VIMRUNTIME/filetype.vim, .asm, .s, .S, .a, .A, .mac and .lst files will all be recognised as Assembler. If you are having a different extension, look at :set ft to see what it's being recognised. You may need to override it in your ~/.vimrc:
augroup filetypedetect
au BufNewFile,BufRead *.whatever setf asm
augroup END
On you installation, you have a file called syntax\asm.vim which should define color syntax rules for assembly.
On my installation, I got the following line:
syn match asmComment "[#;!|].*" contains=asmTodo
Which means that lines starting by # (or ;) should be considered as comments and it does work on my installation.
You can check in filetype.vim if the file you are working on is recognized as asm.
In your .vimrc or .gvimrc which are vim configuration files, you need :
" Syntax highlighting and filetypes
filetype plugin indent on
syntax on

How does one align code (braces, parens etc) in vi?

How do you prettify / align / format code in vi? What is the command?
I have pasted in a hunk of code and I need to have it all formatted/aligned... obviously I am a vi neophyte.
x
These commands in my answer work in vim. Most people who think they're using vi are using vim. To find out if your 'vi' is really 'vim', open vi and type :version -- if it's vim, it will say so. Otherwise you might just see a version number without the name of the program. Also, when you open vim for the first time you will usually see a splash screen of some sort that says "VIM - VI iMproved"...
Automatic Indentation
To turn auto-indentation on, make sure vim knows the file type you're editing (it usually automatically detects this from the file name extension, but might not figure it out with some file types). You can tell it the filetype using the menus for syntax highlighting. Then, do this:
:filetype indent on
You can disable auto-indentation with
:filetype indent off
Automatically adjusting/correcting indentation
In general, ={motion} will align code to an indentation level.
== align the current line
=i{ align the inner block
=% align to the matching parenthesis/bracket under the cursor
=14j or 14== align the next 14 lines
=G align to the end of the file
vG= same thing, align to the end of the
file (but using visual mode)
vjjj= align four lines (using visual mode)
Manual indentation
If vim is not guessing the indentation level correctly, there are two ways to change it:
If you are in normal mode (where everything is a command), do << to shift a line left, or >> to shift it right by one tab. You can do this with several lines by using the same movement commands I showed above (eg, >i{ indents the current inner code block).
If you are in insert mode, you can indent the line further (without moving the cursor) by doing a Ctrl-T, or un-indent one tab with Ctrl-D
Aligning equals signs, etc
If you want to align equals signs in a list of declarations, you should consider using this vim script: http://www.vim.org/scripts/script.php?script_id=294
Adjusting indentation/tab sizes
If you want vim to use spaces instead of tabs when it indents, run this command (or consider adding it to your vimrc file)
:set expandtab
To set how many spaces equal a tab, I usually do this:
:set expandtab softtabstop=3 tabstop=3 shiftwidth=3
tabstop - how many columns a tab counts for (affects display of existing tab characters)
shiftwidth - controls reindentation size with << and >>, among other commands.
softtabstop - how much space to insert when you press the tab key
expandtab - expand tab keys to spaces
But if you have to work with different amounts of tabs a lot, you could also use this function and keybinding:
function! Ktabs(tabsize)
execute "set softtabstop=" . a:tabsize . " tabstop=" . a:tabsize . " expandtab shiftwidth=" . a:tabsize
"set softtabstop=a:tabsize tabstop=a:tabsize expandtab shiftwidth=a:tabsize
endfunction
noremap <leader><Tab> :call Ktabs(3)<Left>
If you are editing a file with a mix of tabs and spaces, you may want to use this command after setting tab size:
:retab
={motion}
:h =
P.S. You shouldn't use vi if vim is available.
If manually adjusting indents I will open a visual block with V on the first or last line I want to re-indent, move to the brace containing the block, goto the other brace with % then shift the line with > or <
If indents are off by a lot I will shift everything all the way left with < and repeat it with . and then re-indent everything.
Another solution is to use the unix fmt command as described in Your problem with Vim is that you don't grok vi., {!}fmt

Resources