You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`:r filename`| Insert the contents of "filename" into the current buffer. |
112
114
|`:w filename`| Save the current buffer to "filename". |
113
-
|`"*y`| Yank (copy) text to the system clipboard. |
114
-
|`"*p`| Paste text from the system clipboard. |
115
+
|`"*y`| Yank (copy) text to the system clipboard (some versions of vim do not support this). |
116
+
|`"*p`| Paste text from the system clipboard (some versions of vim do not support this). |
115
117
116
118
## The .vimrc file
117
119
@@ -131,6 +133,7 @@ Here are some common `.vimrc` customizations to enhance your Vim experience:
131
133
### **Basic Settings**
132
134
133
135
```vim
136
+
set mouse+=a " turn on mouse in all modes
134
137
set number " Show line numbers
135
138
set relativenumber " Show relative line numbers
136
139
set cursorline " Highlight the current line
@@ -140,12 +143,19 @@ set expandtab " Convert tabs to spaces
140
143
set autoindent " Maintain indentation level
141
144
set nowrap " Prevent line wrapping
142
145
```
146
+
147
+
-**Mouse Usage**: `set mouse+=a` turns mouse usage on in all vim modes (normal, visual, insert, and command-line). This allows you to use the mouse for various actions like selecting text, resizing windows, and scrolling.
143
148
-**Line Numbers:**`set number` displays absolute line numbers, while `set relativenumber` makes navigation easier by showing relative numbers.
144
149
-**Cursor Highlighting:**`set cursorline` makes it easy to see where your cursor is.
145
150
-**Indentation Control:**`tabstop`, `shiftwidth`, and `expandtab` ensure consistent spacing and indentation.
146
151
-**Autoindent:** Helps maintain indentation consistency when writing code.
147
152
-**Text Wrapping:**`set nowrap` prevents long lines from wrapping, keeping code readable.
148
153
154
+
155
+
{% hint style="info" %}
156
+
**Copy-Paste Issues**: Enabling mouse support might interfere with terminal copy-paste shortcuts. Use Shift or Ctrl keys as modifiers if needed (usually hold shift along with normal selection, then copy)
157
+
{% endhint %}
158
+
149
159
### **Search & Navigation**
150
160
151
161
```vim
@@ -154,6 +164,7 @@ set smartcase " Override ignorecase if uppercase is used
154
164
set incsearch " Highlight matches as you type
155
165
set hlsearch " Highlight all search matches
156
166
```
167
+
157
168
-**Case Handling:**`ignorecase` makes searches case-insensitive, while `smartcase` ensures uppercase queries remain case-sensitive.
158
169
-**Incremental Search:**`incsearch` highlights matches as you type, providing instant feedback.
159
170
-**Highlighting Matches:**`hlsearch` ensures all found results are highlighted for better visibility.
@@ -167,6 +178,7 @@ nnoremap <leader>x :x<CR> " Save and exit with <leader>x
167
178
nnoremap <leader>n :bnext<CR> " Move to next buffer
168
179
nnoremap <leader>p :bprevious<CR> " Move to previous buffer
169
180
```
181
+
170
182
-**Leader Key Shortcuts:** These mappings allow quick execution of common tasks using a single key combination.
In Vim, the **leader key** is a customizable key that serves as a prefix for user-defined shortcuts, making commands faster and more intuitive. By default, the leader key is set to `\` (backslash), but it can be changed to another key, such as the **comma** or **space**, to improve usability.
179
191
180
192
### **Why Use the Leader Key?**
193
+
181
194
-**Simplifies Commands:** Instead of typing long Vim commands, you can assign shortcuts to them.
182
195
-**Improves Speed:** Reduces keystrokes for common actions.
183
196
-**Personalized Workflow:** Tailor Vim to your habits and needs.
184
197
185
198
### **Setting a Custom Leader Key**
199
+
186
200
You can redefine the leader key in your `.vimrc` file:
201
+
187
202
```vim
188
203
let mapleader="," " Set leader key to comma
189
204
```
190
205
191
206
### **Using the Leader Key**
207
+
192
208
Once defined, the leader key can be used to create custom shortcuts:
209
+
193
210
```vim
194
211
nnoremap <leader>w :w<CR> " Save file with ,w
195
212
nnoremap <leader>q :q<CR> " Quit Vim with ,q
196
213
nnoremap <leader>x :x<CR> " Save and exit with ,x
197
214
```
215
+
198
216
This means pressing **`,` followed by `w`** will save the file instead of typing `:w<CR>` manually.
0 commit comments