Sublime Forum

Basic code writing questions

#1

Hey there,

Recently I’ve started to use Sublime Text 2 and I’m loving it :smile: I always used dreamweaver but it had so many options I didn’t use. Anyways, I have a couple of very basic questions.

  1. When I’m writing code (for example CSS). I usually type this:

body {
color: green;
}

Sublime text automatically creates ; at the end (which is great!) but I always have to use my arrow keys on my keyboard to get behind the ; and press enter to create a new line. (because right now I am typing between the ‘n’ from ‘green’ and the ; ) This is pretty annoying. Is there any other way than using my arrow keys or just typing the ; instead? (I have the same problem when making jQuery functions, I always have to press the right arrow key to continue typing because Sublime Text 2 automatically creates these parenthesis. () {} I dont want to turn this function off I just want to type faster without having to use my arrow keys all the time to navigate in the code.

  1. copy pasting. Whenever I copy paste a code it creates extra space. For example I’m using CTRL + C to copy and CTRL + V to copy this:
  • 1
  • 2
  • 3

and it comes out like this:

___________


  • 1
  • 2
  • 3

____ = spaces

is there any way to make this easier so I dont have to remove the unnecessary space?

  1. Sometimes I see people just typing ul>li and it automatically creates an unordered list items. How do I do this? or just typing .hello creates a div with a class ‘hello’.

  2. When I’m typing

      I can press enter and it also creates a
    (which is good). But then I have to press enter twice and it’s pretty difficult creating a vertical space between the
      and
    . For example to create this:
  • 1
  • 2
  • 3

Thanks in advance :smile:

0 Likes

#2
  1. Add the following to your user keybindings: [code] { “keys”: “tab”], “command”: “move”, “args”: {“by”: “characters”, “forward”: true}, “context”:

     { "key": "following_text", "operator": "regex_contains", "operand": "^)\"'\\]\\};]", "match_all": true },
     { "key": "auto_complete_visible", "operator": "equal", "operand": false },
     { "key": "has_next_field", "operator": "equal", "operand": false }
    

    ]
    }[/code]

  2. Add this to your user keybindings as well: { "keys": "super+shift+v"], "command": "paste" }, { "keys": "super+v"], "command": "paste_and_indent" }

  3. Install the ZenCoding plugin

  4. I’m not really sure what your question is here. If you install the Tag plugin, it will auto-close tags when you press </. Alternatively, you can change autocomplete to commit on tab instead of enter.

For tab autocompletion, add this to Preferences > Settings - User:

"auto_complete_commit_on_tab": true
0 Likes

#3

you might want to check Edit -> Text -> Insert line before/after shortcuts

0 Likes

#4

Thank you for the responses :smile: I still don’t know how to get to the end of a line of code. Any help there?

0 Likes

#5

ctrl+enter

0 Likes

#6

If you added my first keybinding, tab should move you past the semi-colon. However, if you want to move directly to the end of the line no matter where you are, you can add this: { "args": { "extend": false, "to": "hardeol" }, "command": "move_to", "keys": "ctrl+quote" ] }

0 Likes