I'm writing script in TCL and want to know, how can I fix the beginning of each line automatic?
each line begin is different tab amount and I want to fix it automatically?
In Emacs I know I can press TAB each line to reorder start line position.
How can I do it in GVIM?
Related
99.9% of the time, I have line-wrapping turned off in vim. But there are the rare occasions (usually, when looking at a generated debug or build log) where there is some egregiously-long line that I don't want to slowly scroll through.
Is there a vim command that will soft-wrap ONLY the current line, that can be just as quickly undone by another (or the same) vim command? By "soft-wrap", I mean vim will only change the line's visual representation on the screen, not actually permanently break it up within the file buffer.
BONUS: can this line be temporarily colored differently, to make it more obvious where it begins and ends? (I do not use line numbers, as they complicate copy-paste from within an xterm or tmux.)
You can't soft wrap just one line, but you could reformat it with gqq, then hit u to undo when you're done.
You can highlight the current line with :set cursorline, though this would work better with :set wrap.
while in insert mode in vim how do i move to a new line correctly indented.
In many editors this action would be CTRL+ENTER
There is a similar stackoverflow question here however this answer takes you back to the start of the current line SO start of current line
So assuming this is my code, my cursor is just at the T in POST and i want to go to the start of the next line or next line with correct indentation if its a function(using snippets for function so now great concern).
#app.route('/add', method=['POST | '])
expected result
#app.route('/add', method=['POST'])
|
I would use <esc>o. Assuming you have filetype plugin indent on in your vimrc o will automatically go to the correct indent level.
Search for indentation and map to some keys, so you cannot search for every time.
/^^I
^I is tab
When I scroll down a page the relative numbering is no longer based upon the cursor position.
Instead the line position relative to the top of the screen is displayed.
Sometimes I would like to delete or yank 200 lines and I dont want to have to do the subtraction and addition to figure out how many lines down my text is.
How can I show relative line numbers to the cursor even when scrolling?
I think what you want is, you scroll with mouse, and expect that vim keeps the cursor in original place. E.g. your cursor is at line 5, and you scroll down 5000 lines, you expect your cursor is still at line 5. That is, the cursor is out of the window.
AFAIK, the cursor won't go out of the window. That means, if you keep scrolling down, and the cursor line will be the top line of your current window. and the rnu are gonna re-calculated by the cursor line.
May be you could just explain what do you want to do. the cases in your question could be done by 200dd or 200Y but I guess it is not as simple as that.
You may want to find out the ending line by reading/scanning your text lines, and pick the line number (rnu), and do a xxxdd if this was the case. Here you should use normal line number. e.g. your cursor was at line 5, and you scroll down a lot, find the line you want to delete till from line 5. you could do :5,.d vim will delete from line 5 to your current line.
Or you can do 5, 23452d if you find out the lines between 5 and 23452 need to be removed.
If you can search your ending line by /pattern search, vim can do :.,/foo/d this will delete from current line till the next line, which matches foo.
You can still press V enter line-wise visual mode, and moving down by vim-motions. when it reaches the point you want to remove/yand press Y or d
You can take a look this Question/answer:
VIM to delete a range of lines into a register
At the end, I suggest you not using mouse in vim.
This is probably because the cursor moves down a page when you scroll down a page. In vim, the cursor is always on the screen. If you're scrolling down with, say, the mouse wheel, the cursor will just get "stuck" on the top line (modulo scrolloff) and stay there as you continue to scroll down.
Perhaps use ShiftV to start a line-based visual selection before scrolling, then use d or y on the selection?
I can confirm that the desired feature is available in Visual Studio Code (VSC) with the Vim extension installed. This is because VSC does not function like Vim by default and holds the cursor in place like other text editors do. This feature not only makes VSC bearable but proves more useful than vanilla Vim when coding large blocks of code also.
Additionally, VSC also allows for easy and language agnostic comment/uncomment toggling with <Ctrl> + / which is also very useful when used together with the above feature.
I have a few text files, each for its own purposes. (Like: download.txt, questions.txt, word-meaning.txt etc.)
questions.txt:
I put all my question, doubt approaching in my mind to this file to ask/clear when I go online (I've no access to internet everytime of the day). I delete that line from the file when I ask that question.
download.txt:
I keep names of all packages or zipballs or tarballs in this file and download when I am connected.
word-meaning.txt:
I am not a native English speaker, so whenever I see any word which's meaning I don't in my native language, I write that down in this file and use Google Translate to translate it to my native language when I am connected.
In all above cases I have to go to last line of the file everytime I have to add anything to those lists.
My Question:
Can I make vim go to line line, last character of the file and then go in in insert mode? I will alias that to something like vimll to use it with these type of files.
Similar Question:
How do I start vim in insert mode?
You can define an autocmd to go into insert mode at the end of the file whenever one of your files is loaded into a Vim window:
autocmd BufWinEnter questions.txt,download.txt,word-meaning.txt $|startinsert!
You can do this in terminal:
vim filename.ext +$ +starti!
To go to the last line, last character of the file filename.ext and then in insert mode.
You can also alias that for your convenience of use, so add the following in your .bash_aliases file:
alias vimll='vim +$ +starti!'
It is very inconvenient when the line I'm editing is at the bottom of the screen . Because you can't see any following lines and that prevent you from take any "eye refernce" to the content of the file following the current line .
so my question is there a vim command can refresh the display and put the current line under edit to on the top of the screen ? thanks in advance.
See this reference.
z<return>
:h scroll-cursor
Jonathan's answer is valid, however I prefer zt (as "top") that keeps the cursor where it was. In the same idea, there is zb (as "bottom") and zz (not as "middle", but that puts the current line at the center of the window).
There is also an option to make vim always show context around the current line:
:set scrolloff=5
(or, :se so=5) will show +/−5 lines around your current line. From vim's help about 'scrolloff':
Minimal number of screen lines to keep above and below the cursor. This will make some context visible around where you are working. If you set it to a very large value (999) the cursor line will always be in the middle of the window (except at the start or end of the file or when long lines wrap).